angularJs ng-repeat ...动态ng-include,ng-controller,ng-init

时间:2016-09-25 05:38:19

标签: angularjs ng-repeat ng-controller angularjs-ng-include ng-init

我希望能做到。

<div ng-include="'templates/control/title.html'" ng-controller="titleCtrl" ng-init="ControlInit('00001')"></div>
<div ng-include="'templates/control/title.html'" ng-controller="titleCtrl" ng-init="ControlInit('00002')"></div>
<div ng-include="'templates/control/title.html'" ng-controller="titleCtrl" ng-init="ControlInit('00003')"></div>

所以,ng-repeat完成了它。

<div ng-repeat="control in Controls" ng-include="'control.ctrlUrl'" ng-controller="control.ctrlName" ng-init="control.ctrlInit + '(' + control.ctrlCode + ')'"></div>

不工作...... 为什么不呢?

请....答案代码......例子......

1 个答案:

答案 0 :(得分:0)

您不需要将control.ctrlUrl放在'单引号内。试试这个:

<div ng-repeat="control in Controls" ng-include="control.ctrlUrl" ng-controller="control.ctrlName" ng-init="control.ctrlInit + '(' + control.ctrlCode + ')'"></div>