下面是我如何從點擊獲取範圍。有沒有更簡單的方法來獲取子範圍?謝謝。angularjs從點擊元素獲取當前範圍
.chatMsg(ng-repeat='chatMsg in chatLog', ng-class="{active: detailed}", ng-click="openChatDetail($event)")
.text {{chatMsg.foo}}
$scope.openChatDetail = function(e) {
var childScope = angular.element(e.currentTarget).scope()
if (childScope.detailed) {
childScope.detailed = false
return
}
childScope.detailed = true;
}
我想,當它在詳細模式年開幕活動類添加到聊天消息。
請提供一些詳細信息,關於你想要做什麼,跨越示波器將阻礙您單元測試控制器的能力。可能有更好的方法,而不是直接訪問子範圍。 – Brocco
@Brocco你說得很對不起,我添加了這個信息。 – Harry