search

Home  >  Q&A  >  body text

angular.js - angularjs在一个ng-click中实现多个表达式

<span title="保存"
    ng-if="item.$editing" 
    ng-click="item.$editing=false" 
    ng-click="save(item)">
</span>

<!-- 上面有两个ng-click,这样写不对,我想在一个ng-click中实现,求解决方法!谢谢!-->

给我你的怀抱给我你的怀抱2744 days ago486

reply all(2)I'll reply

  • PHPz

    PHPz2017-05-15 17:06:25

    <span title="保存"
        ng-if="item.$editing" 
        ng-click="item.$editing=false; save(item)">
    </span>

    reply
    0
  • 为情所困

    为情所困2017-05-15 17:06:25

    Why not put item.$editing=false; inside a function, such as editSave()?

    function editSave(item){
        item.$editing=false;
        save(item);
    }
    <span title="保存"
        ng-if="item.$editing"
        ng-click="editSave(item)">
    </span>
    }

    It’s better to put the logic code in the controller

    reply
    0
  • Cancelreply