javascript - Angularjs : Controller values not getting displayed in html page -
I still started learning angular. Js. I wrote a basic controller in the app.js file and set its property. I am trying to access this data inside the HTML page but is in vain. The code below is not being shown to the controller property values in the webpage:
app.js:
(function () {var app = angular.module ('gemStore ', []); Var gem = {name:' diamond ', value: 120, description:' hard '}; app.controller (' StoreController ', function) (this.product = gem;});}) );
index.html
& lt ;! DOCTYPE html & gt; & Lt; Html ng-app = "gemStore" & gt; & Lt; Top & gt; & Lt; Meta charset = "ISO-8859-1" & gt; & Lt; Title & gt; Insert title here & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Script type = "text / javascript" src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js" & gt; & Lt; / Script & gt; & Lt; Script type = "text / javascript" src = "js / app.js" & gt; & Lt; / Script & gt; & Lt; P & gt; {{"Hello, Connor!"}} & Lt; / P & gt; & Lt; Div ng-controller = "store as store controller" & gt; & Lt; H1 & gt; {{Store.product.name}} & lt; / H1> & Lt; H2 & gt; {{Store.product.price}} & lt; / H2 & gt; & Lt; H3 & gt; {{Store.product.description}} & lt; / H3 & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Please tell me where I am wrong !! "Syntax" was added in 1.2.0 (or around), I was not thinking '1.0.7'. Try to use a newer version of glass if you are connected with 1.0.7 then you need to use the $ scope
.
Comments
Post a Comment