2016-10-19 62 views
0

我的應用程序結構,如:角1.5,UI路由器+資源+組件,stateProvider找不到組件

app/ 
    js/ 
    levels/ 
      level-create 
      level-edit 
      level-list/ 
        level-list.template.html 
        levellist.component.js 
      level-show/ 
        level-show.template.html 
        levelshow.component.js 
    levels.module.js 

我也有我注入到每一個部件和路由文件的基本資源服務:

'use strict'; 
module.exports = angular 
    .module('app.levels.route', []) 
    .config(function($stateProvider) { 
     $stateProvider.state({ 
      component: 'levellist', 
      name: 'levelIndex', 
      url: '/levels', 
      template: '<levellist></levellist>' 
     }).state({ 
      component: 'levelshow', 
      name: 'levelShow', 
      url: 'levels/:id', 
      template: '<levelshow></levelshow>' 
     }); 

    }); 

與levellist組件都工作正常,但與levelshow它只是無法找到此組件...此外,我已經注意到,stateProvider組件的搜索引擎是非常具體的。 有levelshow.component.js

'use strict'; 
var angular = require('angular'); 

module.exports = angular 
    .module('app.levelsshow.component', ['ngMaterial']) 
    .component('levelshow', { 
     controller: LevelShowController, 
     templateUrl: '/app/js/levels/components/level-show/level-show.template.html' 
    }); 

LevelShowController.$inject = ['Level', '$scope', '$stateParams']; 

function LevelShowController(Level, $scope, $stateParams) { 
    $scope.levelShow = Level.get({ id: $stateParams.id }); 
} 
+0

你所說的「崩潰」的意思exaclty?一些日誌可能? –

+0

您在這裏有一個多模塊應用程序。你不需要在'app.levels.route'中注入levelshow的模塊'app.levelsshow.component'作爲依賴嗎? – tanmay

+0

在我看來,路由文件找不到下一個組件levelshow,所以它只是不顯示任何erros。我將它全部注入到一個模塊level.module.js中。我需要所有這些文件,所以它可以與levellist.component.js一起使用 –

回答

0

是問題是solwed。有沒有必要,以紀念$ stateProvider.state組件標籤