$http 呼び出しから templateurl をロードしたい。
$stateProvider
.state('home', {
url: '/',
templateUrl: will be served by $http call from server
});
これをどのように実装するかを提案してください。
$http 呼び出しから templateurl をロードしたい。
$stateProvider
.state('home', {
url: '/',
templateUrl: will be served by $http call from server
});
これをどのように実装するかを提案してください。
templateProvider ( https://github.com/angular-ui/ui-router/wiki ) を使用し、次のようなテンプレートを含む JSON オブジェクトを取得しました。
templateProvider: function($http) {
return $http.get("http://example.com/returnJSONobject")
.then(function(res) {
return res.htmlTemplate;
});
},
templateUrl は、簡単に実行できる関数にすることもできるため、次のようにします。
$stateProvider.state('home', {
templateUrl: function ($stateParams){
$http....success({
return <whatever> + '.html';
})
}
})
結果からテンプレートに入力し、テンプレートからスコープ値をバインドするには、コントローラーが必要です。
$stateProvider
.state('home', {
url: '/',
templateUrl: 'index.html',
resolve {
results: function($http){
return $http({method: 'GET', url: '/serverspi'})
.then (function (data) {
return process(data);
});
},
}
});