0

我想通过 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>

谢谢你的帮助!

4

1 回答 1

3

像这样做:

function PropertyCtrl($scope){
    $scope.active;
    $scope.activate = function(property){
        $scope.active = property;
    }
}

HTML:

<a href="" ng-click="activate(property);">{{property}}</a>
于 2013-05-16T12:42:36.400 回答