我想通过ng-click为变量赋值,如教程页面所示,但它不能解决jet问题。我做错了什么?
<div ng-controller="PropertyCtrl" ng-init="active='Please select an option'">
<div class="left-third" >
<ul>
<li ng-repeat="property in properties">
<a href="" ng-click="active='{{property}}'">{{property}}</a>
</li>
</ul>
</div>
<div class="right-rest">
<h4>{{active}}</h4>
</div>
</div>
感谢您的帮助!
答案 0 :(得分:3)
这样做:
function PropertyCtrl($scope){
$scope.active;
$scope.activate = function(property){
$scope.active = property;
}
}
HTML:
<a href="" ng-click="activate(property);">{{property}}</a>