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:



filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:



My Personal Notes arrow_drop_up

Recommended Posts: