角度组件不呈现模板

时间:2017-01-25 12:18:52

标签: javascript angularjs angular-ui-router

基于public static <T> List<T> splitCommaSeparatedStringToList(String s, Function<String, T> function) { if (isNull(s)) { return Collections.emptyList(); } return FluentIterable.from(Arrays.asList(s.split(COMMA))).transform(function).toList(); } 的教程  (https://ui-router.github.io/ng1/tutorial/hellogalaxy)我在Angular应用程序中有这些状态:

UI-Router

这是我的另一个包含模块声明的文件:

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>' }) 按钮时,没有模板,只有空白且没有错误。由于没有错误,因此很难调试。我在这里缺少什么?

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

您最有可能找到了解决方案,但是无论如何这里都可以解决。

在该示例中,所有组件都是同一个角度模块(“ hello”)的一部分,而您已将组件添加到单独的模块中。

您需要添加 TalentForce_Application 作为对主模块 appRoutes 的依赖。

Public Class _1_5_register_event_s2
Private Sub _1_5_register_event_s2_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim optionA As String = "Option A ($0):  "
    Dim food As String = "Pasta"

    optionA = FontStyle.Bold
    food = FontStyle.Regular

    rb_optionA.Text = optionA & food

End Sub
相关问题