动态加载页面转换成格使用angularJS [英] Loading dynamically pages into div using angularJS
问题描述
我试图动态加载的网页到 DIV
使用选择
I'm trying to load pages dynamically into a div
using a select
我的HTML code:
My HTML code :
<div ng-app="App" ng-controller="ProjectCtrl">
<div>
<select ng-model="selectedType" class="form-control" ng-change="showContent()" ng-options="type as type.text for type in types"></select>
</div>
<div>
<div ng-include src='getView()'></div>
</div>
</div>
我的JS code:
My JS code :
$scope.showContent= function() {
$scope.getView = function() {
return $scope.selectedType.value ;
}
}
我得到这个错误:
I got this error :
错误:[NG:AREQ] <一个href=\"http://errors.angularjs.org/1.2.2/ng/areq?p0=Ctrl&p1=not%20a%20function%2C%20got%20undefined\" rel=\"nofollow\">http://errors.angularjs.org/1.2.2/ng/areq?p0=Ctrl&p1=not%20a%20function%2C%20got%20undefined
Error: [ng:areq] http://errors.angularjs.org/1.2.2/ng/areq?p0=Ctrl&p1=not%20a%20function%2C%20got%20undefined
P.S:我的看法使用angularJS过了,这个想法是从选择
让我的页面(视图)。
Ctrl键是加载页面的控制名称
P.S: My views use angularJS too, and the idea is to get my page(View) from the select
.
"Ctrl" is the control name of the loaded page
推荐答案
看起来像$ scope.selectedType.value被返回null。尝试的console.log
更改$ scope.selectedType,看看你会得到什么。该函数返回的完整路径。
Looks like $scope.selectedType.value is returning null. Try console.log
ging $scope.selectedType to see what you get. The function should return the full path.
更新
审查plnk后,似乎你试图通过加载整个应用角度NG-包括。这不是什么NG-包括做,它只是包括小模板。这里是工作 plnkr
这篇关于动态加载页面转换成格使用angularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!