Angularjs ng在内部单击ng重复不起作用

Angularjs ng在内部单击ng重复不起作用,angularjs,Angularjs,我有html,它看起来像下面的一个,我有2个ng点击在整个代码中,在这两种情况下,我调用相同的函数。这两个功能在同一个控制器中 <div class="tagselect tagselect--frameless"> <div class="combobox__body combobox__body--open combobox__body--frameless" ng-show="focus">

我有html,它看起来像下面的一个,我有2个ng点击在整个代码中,在这两种情况下,我调用相同的函数。这两个功能在同一个控制器中

          <div class="tagselect tagselect--frameless">
            <div class="combobox__body combobox__body--open combobox__body--frameless" ng-show="focus">
                <ul class="list-unstyled">
                    <li class="combobox__item" ng-repeat="pos in listCtrl.positions | filter:query as results"
                        ng-click="listCtrl.choosePosition(pos)">{{pos.name}}
                    </li>
                </ul>
            </div>
          </div>
          <div class="col-md-2 no-padding">
            <button type="button" class="btn btn-success" ng-click="listCtrl.chosenPositions(789456)">Add</button>
          </div>
我仔细检查拼写错误,并确保它不是因为函数(我用简单的控制台日志创建了一个新的)

问题是按钮点击正确调用函数,但ng repeat
  • 不起任何作用。我在angular文档中读到ng repeat创建了新的作用域,但我认为只要我引用object
    listCtrlchoosePosition()

    有人能告诉我我做错了什么吗? 谢谢

    编辑:Plunker示例:
    ng blur
    正在做一些奇怪的事情,因此我建议您更改
    $scope.focus
    值,而不是使用
    ng blur

    html文件

    <!-- more html code -->
    <!-- input without ng-blur directive -->
    <input class="tagselect__input" placeholder="Position" ng-focus="focus=true" ng-model="query">
    <!-- more html code -->
    <li class="combobox__item" ng-repeat="pos in listCtrl.positions | filter:query as results" ng-click="listCtrl.choosePosition(pos)">{{pos.name}}
    <!-- more html code -->
    
    // more code goes here.
    choosePosition: function (position) {
      //alert('Going to choosen position');
      //$scope.query = position.name;
      $scope.focus = false; // Hide div options from here.
      // rest of your code.
    },
    // more code goes here.
    

    在这个

    ng blur
    中工作有点奇怪,因此我建议您更改
    $scope.focus
    中的
    ListCtrl
    值,而不是使用
    ng blur

    html文件

    <!-- more html code -->
    <!-- input without ng-blur directive -->
    <input class="tagselect__input" placeholder="Position" ng-focus="focus=true" ng-model="query">
    <!-- more html code -->
    <li class="combobox__item" ng-repeat="pos in listCtrl.positions | filter:query as results" ng-click="listCtrl.choosePosition(pos)">{{pos.name}}
    <!-- more html code -->
    
    // more code goes here.
    choosePosition: function (position) {
      //alert('Going to choosen position');
      //$scope.query = position.name;
      $scope.focus = false; // Hide div options from here.
      // rest of your code.
    },
    // more code goes here.
    

    在这种情况下工作

    ng repeat返回的位置似乎是一个对象,但是,有效的调用:listCtrl.chosenPositions(789456)正在接收一个原语,因此我认为您应该执行ng click=“listCtrl.choosePosition(pos.someProperty)在您的ng repeatHi@ArturoMontaño中,如果该函数将执行任何操作,而不是像现在一样,那么您将是对的,它只会得到console.log值(我不知道,我对此感到抱歉)。还有一个问题是,如果我在函数内部使用断点,它甚至没有进入函数内部。ng repeat返回的pos似乎是一个对象,但是,有效的调用:listCtrl.chosenPositions(789456)正在接收一个原语,所以我认为您应该执行ng click=“listCtrl.choosePosition(pos.someProperty)在您的ng repeatHi@ArturoMontaño中,如果该函数将执行任何操作,而不是像现在一样,那么您将是对的,它只会得到console.log值(我不知道,我对此感到抱歉)。还有一个问题是,若我在函数内部使用断点,它甚至并没有进入函数内部