Assign the gem property to the scope object.
(function(){
var gem = { name: 'Azurite', price: 2.95 };
var app = angular.module('gemStore', []);
app.controller("StoreController",function($scope){
$scope.product = gem;
});
})();
You would then output the properties of 'product' in StoreController's template.
<div>
{{product.name}}
</div>
<div>
{{product.price}}
</div>
You could put the gem in a service also so it's not just sat there in the closure.
(function(){
var app = angular.module('gemStore', []);
app.controller("StoreController",function($scope, GemSvc){
$scope.product = GemSvc.getGem();
});
app.service("GemSvc",function(){
var gem = { name: 'Azurite', price: 2.95 };
this.getGem = function () {
return gem;
};
});
})();
Then in your template, i've used the ng-controller method here as you did not state how you hook up your templates to controllers.
<div ng-controller="StoreController">
{{product.name}}
{{product.price}}
</div>