我有一個名爲profile.html的可重用模板。它看起來是這樣的:AngularJS元素的子範圍
<div>
{{firstName}}
</div>
我把它嵌入在這勢必專用控制器另一個模板:
<div ng-include src="'templates/profile.html'"></div>
我要爲這個div創建一個子$範圍。在控制器父模板,我有這樣的:
$scope.profile = theProfile;
我想爲profile.html模板子範圍是父$ scope.profile。類似於:
<div ng-include src="'templates/profile.html'" ng-scope="{{profile}}"></div>
我該怎麼做?
爲什麼不直接寫'{{profile.firstName}}'? – floribon
您無法將任意對象轉換爲範圍。 –