i just started angular ..pls help me

31 views
Skip to first unread message

abhi ram

unread,
Jun 12, 2019, 11:31:59 PM6/12/19
to Angular and AngularJS discussion
<!DOCTYPE html>
<html lang="en-US">
<body>

<div ng-app="">
  <p>Name : <input type="text" ng-model="name"></p>
  <h1>Hello {{name}}</h1>
  <p>sum={{ 5 + 5}}</p>
</div>
<div data-ng-app="">
<p>sum={{ 5 + 5}}</p>
</div>

</body>
</html>
 i dont know why it showing different output

Screenshot_2019-06-12 Screenshot.png

Chiheb Ben Jemia

unread,
Jun 13, 2019, 4:55:19 AM6/13/19
to Angular and AngularJS discussion
hi
1/ ng-app and data-ng-app are the same thing, except validation...
2/ ng-app is used in one time to define your app...

so, in your exemple, only the first div (ng-app) will take effect, the second div (data-ng-app) will be considered as a simple html...

Chiheb Ben Jemia

unread,
Jun 13, 2019, 5:14:48 AM6/13/19
to Angular and AngularJS discussion
look at this example...!
ng-app include data-ng-app then it takes effect....but unnecessery to make that! ;)

<!DOCTYPE html>
<html lang="en-US">
<body>

<div ng-app="">
  <p>Name : <input type="text" ng-model="name"></p>
  <h1>Hello {{name}}</h1>
  <p>sum={{ 5 + 5}}</p>

<div data-ng-app="test">
<p>sum={{ 5 + 5}}</p>
</div>

</div>
</body>
</html>
Reply all
Reply to author
Forward
0 new messages