ng-src

What is ng-src:ng-src used with in img tag for display an image on the base of dynamic anularjs expression..
Description of ng-src:ng-src has priority 99.
ng-src add and display the image on the bases of dynamic content..
Syntax of ng-src:
<img ng-src="http://www.angularjsexample.com/myimages/{{imgname}}"/>
How to Use ng-src/ng-src Example::
 Example 1:
<div ng-app="webapp">
    <div  ng-init="imgname='abc.jpg'">
        <div>
            Angularjs Example of ng-src
            <img ng-src="http://www.angularjsexample.com/myimages/{{imgname}}" />

        </div>
    </div>
</div>

Example 2:
<div ng-app="webapp">
    <div ng-controller="angularjsexampleCtlr">
        <div>
            Angularjs Example of ng-src
            <img ng-src="http://www.angularjsexample.com/myimages/{{imgname}}" />
        </div>
    </div>
</div>

<script>
    angular.module('webapp', []).controller('angularjsexampleCtlr', function ($scope, $http) {
        $scope.myfun = function () {
            $scope.imgname = 'abc.jpg';
        }
    });

</script>

No comments :

Post a Comment