更新时间:2022-10-29 17:13:39
假设你的code被包裹在里面。
myModule.config(['$ routeProvider',函数($ routeProvider){
//你的code在这里
}]);
这应该工作。也许你可以显示什么路径到您的模板看起来像,因为它可能只是在路径中一个错字。
When I am trying to browse a url which is not in $routeProvider I am getting this error
TypeError: Cannot read property 'templateUrl' of undefined
here is the js code
$routeProvider
.when('/', {
templateUrl: '/MY/home/home',
controller: function($scope) {
//my custom code
}
})
.otherwise({
redirectTo: '/'
});
assuming your code is wrapped inside
myModule.config(['$routeProvider', function($routeProvider) {
//your code here
}]);
this should work. maybe you could show what the path to your template looks like because it might just be a typo in the path.