I need to display an image in angularjs(File in local). by
<img src="imagename.jpg"> and <img ng-src={{imagename.jpg}}
this two methonds. i cant display it. Any help will be appreciated.
You are probably getting an error with $sce in which the image source is not trusted.
Just pass the $sce service as a dependency and use trustAsResourceUrl so that Angular will not throw the error.
app.controller('myCtrl', function($scope, $sce) {
$scope.myImgSrc = $sce.trustAsResourceUrl('path/to/img.jpg');
});
You can then use the $scope property as the img src like this:
<img ng-src="{{myImgSrc}}">
var myapp=angular.module('myapp',[]); app.controller('myCtrl', function($scope, $sce) { $scope.myImgSrc = $sce.trustAsResourceUrl('/Abc_Mobiles/assets/www/partials/345i0iwf.jpg'); }); This is my code.
$scope. Angular things of that as$scope.imagename.jpg, which is not what you want to do :) Does your console show any errors?