我正在使用 Angular js 创建单页应用程序。我正在调用一个函数,该函数返回 data-ng-include 的 url。
示例:
<script>
function theURL(){
return 'demo.html';
}
</script>
<div ng-app="">
<div data-ng-include="'theURL()'">
</div>
</div>
但是上面的代码没有获取从函数返回的 url,因此部分页面未加载。你能帮忙吗?
最佳答案
尝试:
<div ng-include="theURL()"></div>
但是如果它不起作用,你的 Controller 在哪里?你的$scope在哪里?
$scope.theUrl = function(){
return 'demo.html';
}
这在你的 Controller 内将 100% 工作。
关于javascript - Angularjs data-ng-include 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35554396/