1

I need to add logic as witch image to show

here is some code i think it would work:

view:

<img ng-src="{{checkImage(data.image)}}" />

js

function checkImage(img){
  if(img==1){
    return "image/1.jpg";
  }
}
4

1 回答 1

3

You should put the function in ng-controller

function ctrl($scope) {
    $scope.data = {};
    $scope.data.image = 1;
    $scope.checkImage = function (img) {
        if (img == 1) {
            return "image/1.jpg";
        }
    }
}
于 2013-08-21T21:03:50.530 回答