angularjs - Why does my ngRoute not do anything? -
i'm trying set ngroute. don't want update view, perform changes scope when route called. have included angular-route.js , ngroute.
angular.module('todo', ['ngroute','ngstorage']). config(function($routeprovider){ $routeprovider. when('/:state',{ controller: 'aspectcontroller' }) }). controller('aspectcontroller', function($scope){ console.log('aspect'); })
the expected outcome when visit page index.html#/test console write "aspect" nothing happens, don't errors or else.
full html:
<!doctype html> <html class="no-js" xmlns:ng="http://angularjs.org" id="ng-app" ng-app="todo"> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge,chrome=1"> <title>todo.txt</title> <meta name="viewport" content="width=device-width"> <link rel="stylesheet" href="css/normalize.min.css"> <link rel="stylesheet" href="css/main.css"> <script src="bower_components/angular/angular.js"></script> <script src="bower_components/angular-route/angular-route.js"></script> <script src="bower_components/ngstorage/ngstorage.js"></script> <script src="js/main.js"></script> </head> <body ngview ng-controller="docontroller"> <ul class="aspects"> <li><a href="#/do">now</a></li> <li><a href="#/deferred">deferred</a></li> <li><a href="#/completed" class="alt">completed</a></li> </ul> <div class="checkboxes"> <div class="checkboxwrapper"> <input ng-repeat="task in $store.taskarr track $index" type="checkbox" /> </div> </div> <textarea autoexpand class="tasks" ng-change="processtasks()" ng-model="$store.tasks"></textarea> </body> </html>
i don't want update view
it sounds me reason don't use ngview
directive in view. in case not able to it, since route change trigger controller if there ngview
available. otherwise doesn't make sense. if don't provide template
or templateurl
controller not triggered too.
Comments
Post a Comment