ng-src with image element

Description

The following code shows how to use ng-src with image element.

Example


<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<script type='text/javascript'>
var myApp = angular.module('myApp', []);
<!--   ww  w .  ja v  a2  s .  c  om-->
myApp.controller('myCtrl',
    function ($scope) {
        $scope.url = 'www.java2s.com/style/download.png';
    }
);
</script>
</head>
<body>
  <div ng-app="myApp">
    <div ng-controller="myCtrl">
        <img src="http://{{url}}"/>
        <img ng-src="http://{{url}}"/>
    </div>
</div>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities