New to Angular - Computed Variables

前端 未结 7 1508
一个人的身影
一个人的身影 2021-02-04 00:33

I am moving to Angular from Knockout, and I have a few issues. I\'m assuming that I must be doing something a non-angular type of way.

http://jsfiddle.net/LostInDaJungle

7条回答
  •  伪装坚强ぢ
    2021-02-04 01:23

    u can bind to a function

    function CTRL ($scope) {
    $scope.val1 = 3;
    $scope.val2 = 4;
    $scope.sum = function(){
       return ($scope.val1 *1 + $scope.val2 *1);
    };
    

    }

    it will work the same the binding expression will work but in much more complex cases we need functions

提交回复
热议问题