2017-01-25 36 views
0

我有这些国家在我的角度应用:角分量不会呈现模板

angular 
    .module('appRoutes', ["ui.router"]) 
    .config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { 

    // An array of state definitions 
    var states = [ 
     { name: 'home', url: '/', component: 'home' }, 
     { name: 'about', url: '/about', component: 'about' }, 

    ] 

    // Loop over the state definitions and register them 
    states.forEach(function(state) { 
     console.log(state.component) 
     $stateProvider.state(state); 
    }); 

    $urlRouterProvider.otherwise('/'); 
}]); 

这里是我的其他文件中包含模块声明:

'use strict'; 

var talentforceApp = angular.module("talentforce", []); 

angular 
    .module('TalentForce_Application', [ 
     'appRoutes', 
     'talentforce', 
     'ngResource' 
    ]); 

以及其中一个简单组件的文件:

talentforceApp.component('about', { 
    template: '<h3>About TalentForce</h3>' 
}) 

当我运行它时,我的控制台没有提供任何错误。我检查了,状态和组件确实保存了。它只是不渲染。当我点击我应用程序的About按钮时,没有模板,只是空白,没有错误。由于没有错误,因此很难调试。我在这里错过了什么?

+0

你的模块是不同的组件和模板 – Sunil

回答

0
angular.module('appRoutes').component('about', { 
    template: '<h3>Template</h3>' 
}) 
+1

它不起作用。结果是一样的。 –