Can not share data between controllers AngularJs -
hi i`m new in angularjs. index.html file http://clip2net.com/s/3oknpg6
<!doctype html> <html ng-app="app"> <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.15/angular-ui-router.min.js"></script> <meta charset="utf-8"> <meta name="description" content=""> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>angular route</title> <link rel="stylesheet" href="css/style.css"> <link rel="author" href="humans.txt"> <script src="angular.js"></script> <script src="node_modules/angular-ui-router/release/angular-ui-router.min.js"></script> <script src="app/app.js"></script> <style> body { padding: 20px; } </style> </head> <body> <div ng-view></div> <script src="js/main.js"></script> </body> </html>
this app.js file:
angular.module("app", ["ui.router"]) .config(function config($stateprovider){ $stateprovider.state("index", { url:"", controller: "firstctrl first", templateurl: "templates/first.html" }) }) .controller("firstctrl", function firstctrl(){ var first = this; first.greeting = "first"; });
and first.html file:
<input type="text" ng-model="first.greeting"/> <div ng-class="first.greeting">{{first.greeting}}</div>
i can not data in view, please me solve issue. i`m getting error: cannot read property 'isdefined' of undefined.
you loading 'ui-router' dependancy twice in index.html. maybe problem? load ui router after have included angular.min.js.
Comments
Post a Comment