东西有线用来在我的代码是发生 所以,我有两个主要的HTML页面可以路由两个HTML页面AngularJS
index.html && adHome.html
他们都使用不同的路线,但是当我试图做到这一点
angular
.module('App', [
'ngRoute',
'ngAnimate',
'ngCookies',
'ngResource',
'ngTouch',
'ngSanitize'
])
.config(function ($routeProvider) {
$routeProvider
.when('/test', {
templateUrl: 'views/user/main.html', //this is called in index.html
controller: 'MainCtrl'
})
.when('/Reports', {
templateUrl: 'pages/Reports.html', //this is called in adHome.html
controller: 'reportController'
})
.otherwise({
redirectTo: '/404' //used by both
});
}
现在,当我尝试运行我的index.html一切的网页似乎正常工作,但是当我尝试在我的adHome.html运行的东西我得到这个错误
Failed to instantiate module flowersApp due to: Error: [$injector:modulerr] http://errors.angularjs.org/1.5.8/ $injector/modulerr?p0=n...)...
我认为这个问题是;因为adHome.html不使用这些:
“ 'ngAnimate', 'ngCookies', 'ngResource', 'ngTouch', “ngSanitize”
有事,我得到一个错误 因为当我删除它们时,似乎在adHome.html Page 上工作,但显然我的index.html页面出现错误,因为我错过了我的注射
有人可以帮我解决这个问题吗?
您注射ngRoute两次 –
啊出于某些原因,第二个方法只是工作,但如果我把它们放在同一注射,然后尝试打电话给他们在adHome.html我似乎得到一个错误 – Obizan
你现在缺少报价在ngSanitize注入 –