Angular expression does'nt work

I'm starting to coding in angular.js on webstorm:

<!DOCTYPE html>
<html ng-app="store">
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body ng-app="store">
<script src="bower_components/angular/angular.js"></script>
<script src="app.js"></script>
<p>Nothing here {{'yet' + '!'}}</p>
{{1 + 1}}
</body>
</html>

but the browser display Nothing here {{'yet' + '!'}} {{1 + 1}}

what can i do?

Answers


You don't provide enough details to resolve the issue, but I made these four changes to your HTML to get it working, at least with respect to AngularJS:

  1. Remove the 'ng-app' attribute from the body tag.
  2. Use a CDN URL for angularjs.
  3. Remove the reference to your js file.
  4. Remove your store app from the 'ng-app' attribute in the html tag.

This modified version of your HTML runs fine using WebStorm:

<!DOCTYPE html>
<html ng-app>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script src="https://code.angularjs.org/snapshot/angular.js"></script>
<p>Nothing here {{'yet' + '!'}}</p>
{{1 + 1}}
</body>
</html>

Once you see that working, you can progressively undo the changes I made (undo 2, then 3 then 4, but retain change 1), and retest to identify the problem.

More details are needed to determine the root cause, but the most likely issues are:

  1. Your angularjs file can't be found.
  2. Your "app.js" file can't be found.
  3. Some problem(s) with your code in app.js.

But since you are using WebStorm, it may be able to identify your precise problem. Run Code=>Inspect Code on your project, then review the output. It will identify very basic problems, such as failing to locate your script files.


Need Your Help

Why does my Android application drain battery?

android sockets battery screen-brightness

I've written a simple application that displays some text and a little bit of graphics on screen. I'm using a Nexus 7, this is for an installation, and as such needs to be on continuously as much a...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.