Angularjs: 从函数中获取 $routeprovider 模板
Angularjs: Get $routeprovider template from function
我一直在阅读文档的一些重要部分,然后我找到了这个页面:https://docs.angularjs.org/api/ngRoute/provider/$routeProvider
在那里的某个地方,它说 route>template
属性 可以是 (String|Function)
.
我猜应该是returns html 成串的函数。我想知道的是是否可以使用 http
请求从服务器获取 html 以及如何编写此类代码。
我知道这会使 angular 在每次导航时请求部分内容,这应该适得其反 - 但我有我的理由。
I guess it should be a function that returns html formed-string.
对,喜欢:
templateUrl: function(param) {
return 'views/' + param.details + '.html' ;
}
What i want to know is if it is possible to use an http request to get the html from the server
不,你不能那样做。
首先加载 config
,您不能将 $http
注入 config
我一直在阅读文档的一些重要部分,然后我找到了这个页面:https://docs.angularjs.org/api/ngRoute/provider/$routeProvider
在那里的某个地方,它说 route>template
属性 可以是 (String|Function)
.
我猜应该是returns html 成串的函数。我想知道的是是否可以使用 http
请求从服务器获取 html 以及如何编写此类代码。
我知道这会使 angular 在每次导航时请求部分内容,这应该适得其反 - 但我有我的理由。
I guess it should be a function that returns html formed-string.
对,喜欢:
templateUrl: function(param) {
return 'views/' + param.details + '.html' ;
}
What i want to know is if it is possible to use an http request to get the html from the server
不,你不能那样做。
首先加载 config
,您不能将 $http
注入 config