URLを '/ nameDisplay'に変更すると、 'nameDisplay'コンポーネントが表示されないようです。エラーは表示されず、テンプレートはui-viewに挿入されません。コンポーネントの代わりに '状態'のテンプレートを使用すると、それ以外の場合は何も表示されません。角度UIルーターを使用してコンポーネントをレンダリング
私が使用しているバージョン管理は次のとおりです。 角度 - 1.5.8 角度UIルータ - 0.3.1
angular.module('app.nameDisplay', [uiRouter])
.component('nameDisplay', {
controller: function(){
this.name = "Keir Beckett";
this.age = 24;
this.changeInfo = function(){
this.name = "Golash Bista";
this.age = 66;
}
},
template: "" +
"<div>" +
"<h2>{{$ctrl.name}}</h2>" +
"<h4>{{$ctrl.age}}</h4>" +
"<button ng-click='$ctrl.changeInfo()'>Change Info</button>" +
"</div>"
}).config(($stateProvider, $urlRouterProvider) => {
$stateProvider.state('nameDisplay', {
url: '/nameDisplay',
component: 'nameDisplay'
})
.state("otherDisplay", {
url: '/otherDisplay',
template: '<h1>Other Display</h1>'
});
$urlRouterProvider.otherwise('/');
})
.name;
を?通常、これは 'template: ' name-display>''を持つことによって行われます。 –
Claies