ngClick在我的角度应用程序中不起作用

时间:2013-05-16 12:37:39

标签: javascript angularjs handlebars.js

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

感谢您的帮助!

1 个答案:

答案 0 :(得分:3)

这样做:

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

HTML:

<a href="" ng-click="activate(property);">{{property}}</a>