1

I using very simple code. I seem to be missing something that does run the Angularjs code.

here is my html code:

<html>
<head>
    <title></title>
</head>
<body ng-app="myAppApp">
<div ng-controller="exempleCtrl">
   HELLO {{name}}!
</div>
</body>
</html>

Here is app.js code:

var app = angular.module('myAppApp',[]);
app.controller('exempleCtrl', function($scope) {
    $scope.name = 'World';
});

I'm new to Angularjs. So I could be missing something big here.

4

1 Answer 1

3

The issue, as pointed out in the comments, is that you did not include your Javascript code in the HTML file. So assuming you called it something like app.js and is in the same directory as the HTML file, then you need to include it as follows:

 <html>
<head>
    <title></title>
    <!-- You should also add reference to angular (use desired version - example here is 1.2.4) -->        
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.min.js"></script>
    <!-- Here including the app.js-->
    <script src="app.js"></script>
</head>
<body ng-app="myAppApp">
<div ng-controller="exempleCtrl">
   HELLO {{name}}!
</div>
</body>
</html>

Give it a try and let us know if this works.

Sign up to request clarification or add additional context in comments.

7 Comments

This is unlikely to work as well since there is no <script> reference to the core Angular library.
Thanks IshmaelMakitla. the code works perfectly. Thank you Lex.
Great! Please accept the answer if you found it useful - this will also mark your question as answered so that it does not appear on the questions queue. Happy coding!
Is there another way to do it without the "<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.min.js">/script>". I mean, can I download the file to local directory and use it?
Yes - you could download it manually and put it under your app folder - OR (and this I prefer) you could use bower.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.