javascript - Display the name of the product inside the <h3> tag -


  1. I am learning angular js

  2. I

  3. But I'm getting this error Display the name of the product within the tag.

  4. How can you decide

  5. / P>

      & lt ;! DOCTYPE html & gt; & Lt; Html ng-app = "gemStore" & gt; & Lt; Top & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "bootstrap.min.css" /> & Lt; Script type = "text / javascript" src = "angular.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "app.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body ng-controller = "Store as Store Controller" & gt; & Lt; Div class = "product line" & gt; & Lt; H3 & gt; {{Store.product.name}} & lt; Em class = "pull-right" & gt; & Lt; / Em> & Lt; / H3 & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

    ) {var gem = {name: 'Azurite', value: 2.95}; var app = angular. Module ('GemStore', [ ];; App.controller ('StoreController', function) (this.product = gem;});}) ();

You should use the $ scope :

  app Controller ('Store Controller', Function ($ Scope)) {$ scope.product = Mani;}); {{Product.name}}  

Please try the following snippet.

  & lt; Script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.2 .23 / angular.min.js" & gt; & Lt; / Script & gt; & Lt; Html ng-app = "gemStore" & gt; & Lt; Top & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "bootstrap.min.css" /> & Lt; Script type = "text / javascript" src = "angular.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "app.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body ng-controller = "StoreController" & gt; & Lt; Div class = "product line" & gt; & Lt; H3 & gt; {{Product.name}} & lt; Em class = "pull-right" & gt; & Lt; / Em> & Lt; / H3 & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;  


Comments