我的切換正常工作,但是當我再次單擊該按鈕時,它不會重置所有。打開的選項卡將保持打開或關閉(如果關閉)。它表現得像它不想重置爲原來的形式。有人建議我什麼我做錯了,請角度js切換事件不能正常工作
<md-card>
<md-card-content>
<button ng-click="Custom()">Cick Here</button>
<div>
<div ng-repeat="search in vm.searchResults">
<md-card ng-click="callaction=!callaction">
<md-card-content>
<br />
<div ng-repeat="sponsor in search.scp">
<div ng-repeat="cin in sponsor.ci">
<div ng-repeat="po in cin.po" >
<p></p>
<span> {{sponsor.Name }}</span>
<span ng-repeat="prod in po.prods">
<img ng-src="{{img/cc2.ico}}">
</span>
<md-list>
<md-list-item ng-hide="callaction">
<div class="outside">
<div ng-repeat="delivery in po.deliveryAddresses" class='extra divInner'>
{{delivery.PracticeName}} <br /> <span ng-show="delivery.LineTwo">{{ delivery.LineTwo}}
</div>
</div>
</md-list-item>
</md-list>
</div>
</div>
</div>
</md-card-content>
</md-card>
</div>
</div>
</md-card-content>
</md-card>
的Javascript
$scope.callaction = true;
$scope.Custom = function() {
$scope.callaction = !$scope.callaction;
};
這是因爲'ng-repeat'創建一個原型繼承的子範圍,你可以通過使用'Dot Rule'或'controllerAs'模式來解決這個問題,我會推薦閱讀[這個答案](https://stackoverflow.com/a/38275584/2435473) –
這就是有趣@PankajParkar。我會按照線索獲取信息。謝謝,希望能解決我的問題,謝謝你的指導 – danny