0

hi everyone i can't understand why my easy code doesn't work

index.html :

<!DOCTYPE html>
<html ng-app="store">
   <head>
      <link rel="stylesheet" type="text/css" href="bootstrap.min.css" />
      <script type="text/javascript" src="angular.min.js"></script>
      <script type="text/javascript" src="app.js"></script>
   </head>
   <body>
      <div ng-controller="StoreController as store">
         <h1> {{store.prodotto.name}} </h1>
         <h2> {{store.prodott.surname}} </h2>
         <p> {{store.prodotto.town}} </p>
      </div>
   </body>
</html>

app.js:

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

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

 var prodotto  = {
     name = 'David',
     surname = 'Gilmour',
     town = 'Cambridge',
     }


 })();

both file are in the same folder with "angular.min.js" and "bootstrap.min.js" .

can anyone help me? thanks very much.

1 Answer 1

4

Working Demo - https://plnkr.co/edit/94hthisj8Psc4Sp13dB1?p=preview


You have some syntax errors in your javascript;

instead of

 var prodotto  = {
     name = 'David',
     surname = 'Gilmour',
     town = 'Cambridge',
     }

use

 var prodotto  = {
     name : 'David',
     surname : 'Gilmour',
     town : 'Cambridge'
     };

In addition, seems you bounded to the wrong variable name

instead of

 <div ng-controller="StoreController as store">
         <h1> {{store.prodotto.name}} </h1>
         <h2> {{store.prodott.surname}} </h2>
         <p> {{store.prodotto.town}} </p>
 </div>

use

 <div ng-controller="StoreController as store">
         <h1> {{store.product.name}} </h1>
         <h2> {{store.product.surname}} </h2>
         <p> {{store.product.town}} </p>
 </div>

https://plnkr.co/edit/94hthisj8Psc4Sp13dB1?p=preview

Sign up to request clarification or add additional context in comments.

3 Comments

see online demo, you bounded to the wrong variable name as well; plnkr.co/edit/94hthisj8Psc4Sp13dB1?p=preview
i copied the code that you post on plunker, but on my computer it doesn't work,. I can't understand.
now i test it again without touching nothing, IT WORK. It doesn't have no sense. so thanks for the help

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.