javascript - How to reference a module variable in an expression? -


i have module , it's variable defined this

var app = angular.module('app',[]); app.value(     'image',     {         id: null,         url: null,     } ); 

in module controller set variable value later on after ajax call. actual value of variable set correctly check controller after call.

i try reference variable html code this

<html ng-app="app"> ... <img ng-src="{{app.image.url}}"> 

for reason expression evaluated empty string. doing wrong?

this happens because app not defined in $scope, have set it:

angular.module('app').controller('somecontroller', function(image) {     $scope.image = image; }); 

then in view:

<html ng-app="app" ng-controller="somecontroller"> ... <img ng-src="{{image.url}}"> 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -