Bootstrap FreeKB - Angular JS - Create images
Angular JS - Create images

Updated:   |  Angular JS articles

In this example, The Angular controller will pass an image from the Controller to the View.



The following Controller contains a variable named profile which contains the path to an image. 

var myApp = angular
	.module("myModule", [])
	.controller("myController", function ($scope) {
	var profile = {
		picture: "images/john_doe.png"		
	$scope.myVariable = profile ;



In the view, the following markup can be used to get the picture from the profile variable. The ng-src directive is used to get the image.

    <script src="js/angular.min.js"></script>
    <script src="js/myAngular.js"></script>
<body ng-app="myModule">
    <div ng-controller="myController">
      <img ng-src="{{ myVariable.picture }}">


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter b12029 in the box below so that we can be sure you are a human.