0
HTML作爲內容內的元件內html和屬性值,訪問控制器功能
<div ng-controller="logCtrl">
<ul>
<li ng-click="logMe" someAttr="hello ricky">hello martin</li>
</ul>
</div>
的Javascript內容,
var app = angular.module('app', []);
app.controller('logCtrl', function ($scope, $element) {
$scope.logMe = function(){
console.log("html content is " + /*---- how can i print $element's inner html text here --- */)
console.log("attribute value is " + /*---- how can i read the li element's someAttr value here --- */)
}
})
這必須在控制檯打印這個消息(當用戶點擊鼠標),
html content is hello martin
attribute value is hello ricky
你可以使用jQuery做..