AngularJS | ng-src Directive
The ng-src Directive in AngularJS is used to specify the src attribute of an <img> element. It ensures that the wrong image is not produced until AngularJS has been evaluated. It is supported by <img> element.
Syntax:
<img ng-src="url"> </img>
Example:
<!DOCTYPE html> <head> <title>ng-src Directive</title> <script src= </script> </head> <body ng-app="app" style="text-align:center"> <h1 style="color:green">GeeksforGeeks</h1> <h2>ng-src Directive</h2> <div ng-controller="geek"> <img ng-src="{{pic}}" /><br><br><br> <script> var app = angular.module("app", []); app.controller('geek', ['$scope', function ($scope) { $scope.pic = }]); </script> </body></html> |
Output:


