2016-03-21 12 views
0

.component()APIを使用してコンポーネント "claList"を作成しています。しかし、それは動作しません。 (私はAngularJS 1.5バージョンを使用しています)以下は私が書いたコードです。AngularJS .component()APIが動作していません

//state configuration 
$stateProvider 
    .state("abc", { 
     url: "/abc", 
     templateUrl: "/index.html", 
     abstract: true 
    }) 
    .state("abc.state1", { 
     url: "/state1", 
     template: "<cla-list></cla-list>" 
    }); 


//JS Code 
var app = angular.module("app"); 
app.component("claList", { //this is not working 
    restrict: "E", 
    templateUrl: "state1.html", 
    controller: state1Controller 
}); 

/*@ngInject*/ 
function state1Controller($scope, $timeout) { 
    .... 
}); 

//HTML code(state1.html) 
<div class="list-container"> 
    <h2 class="text-blue">Header</h2> 
    .... 
</div> 

コンソールにもエラーは表示されません。

+0

ルータが 'abc.state1'ルートに正しくナビゲートしていますか? – Brad

+0

@Brad yes.Its working –

+0

代わりに 'directive(" claList "、{...});'を使ってみましたか? – Brad

答えて

-1

あなたはui-routerを使用していますか?私はここにはっきりと述べていますが、index.htmlの中に入れましたか?

また、コンポーネントに「E」という制限は必要ありません。

関連する問題