angularjs - Trying to add ng-app name does not give expected output in Application -


i trying add ng-app tag in sample angularjs application.

whenever try add name ng-app="myapplication", web page stops working. supposed print name entered in entry box after hello shown below.

enter image description here

the sample code :

<!doctype html> <html lang="en" > <head>     <meta charset="utf-8">     <title>first app</title>     <script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body ng-app="myapplication">     <h1>sample ajs</h1>     <div >         <p>enter name : <input type="text" ng-model="name"></p>         <p>hello <span ng-bind = "name"></span> !</p>     </div> </body> </html> 

if replace ng-app="myapplication" ng-app="" , gives expected output.

i tried using ng-app <div ng-app="myapplication"> ,

<!doctype html> <html ng-app="myapplication" > 

but webpage not populating name entered in text box if giving name ng-app

what going wrong. appreciated !

ide : webstorm2016.2
os: windows 7

edit:
app.js

'use strict';  // declare app level module depends on views, , components angular.module('myapp', [   'ngroute',   'myapp.view1',   'myapp.view2',   'myapp.version' ]). config(['$locationprovider', '$routeprovider', function($locationprovider, $routeprovider) {   $locationprovider.hashprefix('!');    $routeprovider.otherwise({redirectto: '/view1'}); }]); 

the reference myapp module in <div ng-app="myapp"> angular.module('myapp', []). gotta use ng-app="myapp" instead of ng-app="myapplication" @hsiung commented-

"the name of module whatever give first argument, in case 'myapp'. putting ng-app in html let's angular know module want use main application module. way knows 1 want matching names, otherwise won't able find it."

more explanation here ng-app


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -