类型错误:无法读取的未定义的属性'templateUrl“ [英] TypeError: Cannot read property 'templateUrl' of undefined
本文介绍了类型错误:无法读取的未定义的属性'templateUrl“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我试图浏览网址这是不是在$ routeProvider我收到此错误
类型错误:无法读取的未定义的属性'templateUrl
这里是JS code
$ routeProvider
。什么时候('/', {
templateUrl:/我的/ home /家,
控制器:函数($范围){
//我的自定义code
}
})
。除此以外({
redirectTo:'/'
});
解决方案
假设你的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.
这篇关于类型错误:无法读取的未定义的属性'templateUrl“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文