javascript - Why is AngularJS router not triggering? -
i'm trying trigger controller url http://crm.dev/accounts
, i'm using anonymous function in example controller, alert inside doesn't triggered. can't figure out why, guess stupid i'm missing?
i don't want use template or view, need controller fired.
please note i've set $locationprovider.html5mode(true);
.
'use strict'; angular.module('crm', [ 'ngsanitize', 'ngroute', 'angularmoment', 'ui.bootstrap', 'ui.select', 'ui.bootstrap.datetimepicker' ]); angular.module('crm').config(function(uiselectconfig) { uiselectconfig.theme = 'bootstrap'; }); angular.module('crm').constant('angularmomentconfig', { preprocess: 'utc', timezone: 'europe/berlin' }); angular.module('crm').config(['$routeprovider', '$locationprovider', function ($routeprovider, $locationprovider) { $routeprovider. when('/accounts', { controller: function($scope) { alert('test'); } }). otherwise({ redirectto: '/' }); // enable html5mode pushstate ('#'-less urls) $locationprovider.html5mode(true); $locationprovider.hashprefix('!'); }]);
you need have
<ng-view></ng-view>
in main template, otherwise routing system won't work
Comments
Post a Comment