添加多个应用模块时出错 [英] Error when adding more than one app module

查看:117
本文介绍了添加多个应用模块时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个应用程序两个表观模块。为什么我会收到这个错误?我定义了navCtrl在我的index.html文件,其中n-的看法是这样的:

 <机身NG-应用=ciscoImaDashboardAppNG控制器=navCtrl>错误:[NG:AREQ]参数'navCtrl不是一个函数,得到了不确定

我是什么做错了吗?我收到这是因为我在我所有的js文件定义angular.module?

路线JS:

  angular.module('ciscoImaDashboardApp',['ciscoImaDashboardAdmin','ngRoute'])
的.config(函数($ routeProvider){
$ routeProvider
  。当('/管理员',{
    templateUrl:意见/ admin.html
  })
  。什么时候('/', {
    templateUrl:意见/ welcome.html',
    控制器:'welcomeCtrl
  })
  。当('/总-结果',{
    templateUrl:意见/ overall.html',
    控制器:'overallCtrl
  })
  。当('/泳道,结果',{
    templateUrl:意见/游泳lane.html',
    控制器:'swimlaneCtrl
  })
  。当('/键exemplifiers',{
    templateUrl:意见/关键exemplifiers.html',
    控制器:'p​​etalCtrl
  })
});

第二个模块:

  angular.module('ciscoImaDashboardAdmin',[])
.controller('minisCtrl',函数($范围){
});

导航JS:

  angular.module('ciscoImaDashboardApp',['ciscoImaDashboardAdmin'])
.controller('navCtrl',函数($范围,navService,$位置,dummyData){
});


解决方案

正确方法:

  angular.module('ciscoImaDashboarAdmin')
.controller('minisCtrl',函数($范围){
});

删除第二次练习依赖

I am using two app modules in this app. Why do I get this error? I define the navCtrl in my index.html file where ng-view is like this:

<body ng-app="ciscoImaDashboardApp" ng-controller="navCtrl">

Error: [ng:areq] Argument 'navCtrl' is not a function, got undefined

What am I doing wrong? Am I getting this because I define angular.module in all my js files?

Routes JS:

angular.module('ciscoImaDashboardApp', ['ciscoImaDashboardAdmin', 'ngRoute'])
.config(function ($routeProvider) {
$routeProvider
  .when('/admin', {
    templateUrl: 'views/admin.html'
  })
  .when('/', {
    templateUrl: 'views/welcome.html',
    controller: 'welcomeCtrl'
  })
  .when('/overall-results', {
    templateUrl: 'views/overall.html',
    controller: 'overallCtrl'
  })
  .when('/swim-lane-results', {
    templateUrl: 'views/swim-lane.html',
    controller: 'swimlaneCtrl'
  })
  .when('/key-exemplifiers', {
    templateUrl: 'views/key-exemplifiers.html',
    controller: 'petalCtrl'
  })
});

Second Module:

angular.module('ciscoImaDashboardAdmin',[])
.controller('minisCtrl', function ($scope) {
});

Nav JS:

angular.module('ciscoImaDashboardApp',['ciscoImaDashboardAdmin'])
.controller('navCtrl', function($scope, navService, $location, dummyData) {
});

解决方案

right way :

angular.module('ciscoImaDashboarAdmin')
.controller('minisCtrl', function ($scope) {
});

remove dependency practice in the second time

这篇关于添加多个应用模块时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆