在控制器内调用过滤器

时间:2013-08-14 16:52:25

标签: angularjs angularjs-filter

我要做的是在控制器vía数字过滤器内过滤一个模型值,在一个监视功能内,这是代码:

  .controller('FormSectionCtrl', function ($scope,$filter) {
        console.log( $filter('number')(2.4334444,2));   // At this point, the filter works, the problem starts inside de watch...

        $scope.$watch('input19 * constan1 + input20 * constant2', function (value) {

        // $scope.input23 = value;   ...if I do this, the value is correct but with too much digits after point...I just want 2 digits...

        $scope.input23 = $filter('number')(value);  // It doesn't works...
  });
})

出于某种原因,$ filter在手表内部没有显示任何内容......任何人都知道如何正确地做到这一点?

0 个答案:

没有答案