Angular stops working When i use ng-controller in the html tag

msk

I am new in Angular.js and start learning angular on plunker.co. The problem is when I use ng-controller in any tag of html page , angular stops working. I mean {{ 4+4 }} display as it is just after the using of ng-controller.

this is code from Plunker.co

<html ng-app>

  <head>
    <script data-require="[email protected]" data-semver="1.3.15" 
    src="https://code.angularjs.org/1.3.15/angular.js"></script>
    <link rel="stylesheet" href="style.css" />
    <script src="script.js"></script>
  </head>

  <body ng-controller="MainController">
    <h1>Hello Plunker!</h1>
    {{8*8}}
{{message}}

  </body>

</html>

without ng-controller it displays 64 as output but with ng-controller is displays as it is like {{8*8}}. why it is happening. Please give some advice. thnks in advance. :)

script.js

var MainController = function($scope){
  $scope.message = "Hello World!";
}

edited Now message attirbute value is not displaying on page.

Khalid

First try to set a name for your app :

<html ng-app="myApp">

then set a name for your controller :

<body ng-controller="MainController">

and finally, all you need to do is to define your app :

myApp = angular.module('myApp', []);

and try this definition for your controller :

myApp.controller('MainController', function($scope) {
    $scope.message = "Hello World!";
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

when I put ng-controller in div instead of body autocomplete stops working

From Dev

-[UITextView setAttributedText:] stops working, when I use UITraitCollection variations

From Dev

AngularJS stops working as soon as I include a controller

From Dev

ng-click stops working after the first use of $compile when using nested directives

From Dev

the css of my second <article> stops working when I add a new tag after it?

From Dev

I am using Angular js1 .When i use angular select box ng-click is not working

From Dev

ng-click stops working when using ng-if

From Dev

NAnt stops working when I try to run it

From Dev

Angular ng-repeat tag not working

From Dev

css pseudo class stops working when in different tag

From Dev

Foundation 6 (6.2.3) Equalizer stops working when I try to use optional configurations

From Dev

Is it bad to declare ng-app and ng-controller on html tag?

From Dev

Can I init an Angular ngModel in html, and then use its value in controller?

From Dev

How can i use a angular variable coming from controller in html?

From Dev

Can I use interpolation in an Angular controller (not just in the HTML)?

From Dev

Angular: How can I call a controller function from an HTML view using ng-if or another Angular directive

From Dev

use angular variable in tag html

From Dev

Why when i use global vauiable outside the controller return an object when using select_tag?

From Dev

Ng-controller ng-model not working in angular js

From Dev

Ng-controller ng-model not working in angular js

From Dev

Javascript stops working with form tag

From Dev

Javascript stops working with form tag

From Dev

How to use "ng-if" within the Html <a> tag?

From Dev

Use ng-controller inside angular templates

From Dev

Angular code stops working when it's moved to a template file

From Dev

@HTML.ActionLink stops working when new htmlAttribute is added

From Dev

AngularJS - Extra blank option added when i use ng-repeat in select tag

From Dev

Angular ng-style does not automatically apply changes when I change it from controller

From Java

Excel VBA Stops Working When I Add Step Event

Related Related

  1. 1

    when I put ng-controller in div instead of body autocomplete stops working

  2. 2

    -[UITextView setAttributedText:] stops working, when I use UITraitCollection variations

  3. 3

    AngularJS stops working as soon as I include a controller

  4. 4

    ng-click stops working after the first use of $compile when using nested directives

  5. 5

    the css of my second <article> stops working when I add a new tag after it?

  6. 6

    I am using Angular js1 .When i use angular select box ng-click is not working

  7. 7

    ng-click stops working when using ng-if

  8. 8

    NAnt stops working when I try to run it

  9. 9

    Angular ng-repeat tag not working

  10. 10

    css pseudo class stops working when in different tag

  11. 11

    Foundation 6 (6.2.3) Equalizer stops working when I try to use optional configurations

  12. 12

    Is it bad to declare ng-app and ng-controller on html tag?

  13. 13

    Can I init an Angular ngModel in html, and then use its value in controller?

  14. 14

    How can i use a angular variable coming from controller in html?

  15. 15

    Can I use interpolation in an Angular controller (not just in the HTML)?

  16. 16

    Angular: How can I call a controller function from an HTML view using ng-if or another Angular directive

  17. 17

    use angular variable in tag html

  18. 18

    Why when i use global vauiable outside the controller return an object when using select_tag?

  19. 19

    Ng-controller ng-model not working in angular js

  20. 20

    Ng-controller ng-model not working in angular js

  21. 21

    Javascript stops working with form tag

  22. 22

    Javascript stops working with form tag

  23. 23

    How to use "ng-if" within the Html <a> tag?

  24. 24

    Use ng-controller inside angular templates

  25. 25

    Angular code stops working when it's moved to a template file

  26. 26

    @HTML.ActionLink stops working when new htmlAttribute is added

  27. 27

    AngularJS - Extra blank option added when i use ng-repeat in select tag

  28. 28

    Angular ng-style does not automatically apply changes when I change it from controller

  29. 29

    Excel VBA Stops Working When I Add Step Event

HotTag

Archive