我正在尝试触发此URL http://crm.dev/accounts
的控制器,我只是在此示例中为控制器使用匿名函数,但内部警报不会被触发。我无法弄清楚为什么,猜猜这是我愚蠢的东西?
我不想使用模板或视图,我只需要触发我的控制器。
请注意,我已设置$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 for pushstate ('#'-less URLs)
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
}]);
答案 0 :(得分:0)
你需要一个
<ng-view></ng-view>
在您的主模板中,否则路由系统将无法正常工作