0

I have app.js file that contains the following code:

(function () {
var app = angular.module('store', []);

app.controller('StoreController', function () {
    this.product = gem;
});

var gem = {
    name: 'Dodechaedron',
    price: 2.95,
    description: '...',
};

})();

I also have the following html file that contains the following code:

<div ng-app="StoreController as store">
    <h1>{{store.product.name}}</h1>
    <h2>{{store.product.price}}</h2>
    <p>{{store.product.description}}</p>
</div>
<script src="Scripts/angular.min.js"></script>
<script src="app.js"></script>

it also includes

<html xmlns="http://www.w3.org/1999/xhtml" ng-app="store">

When I build the app - nothing happens. The question is - where is mi data from the app.js file?

Thank you.

3
  • What are you doing with StoreController as store? Commented May 20, 2014 at 18:12
  • I call the StoreController and give it the alias - store Commented May 20, 2014 at 18:12
  • I would recommend using $scope variables to store data and keep static data like above in its own factory/service. Commented May 20, 2014 at 18:20

2 Answers 2

1

You're using ng-app instead of ng-controller. If your change your html to this it should work:

<div ng-controller="StoreController as store">
Sign up to request clarification or add additional context in comments.

Comments

1

Your app name should be store.

<html ng-app='store'>

StoreController is a controller so it should be used in ng-controller

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.