How to declare scope property as a object
{
name: ‘The Book of Trees’,
price: 19
}
same here problem please get me solution
$scope.product = {
name: 'The Book of Trees',
price: 19
}
app.controller(‘MainController’,
[’$scope’, function($scope) {
$scope.title = ‘My First Angular Program’;
$scope.promo = ‘Let me learn’;
$scope.product = {
name: ‘The Book of Trees’,
price: 19
}
}]);
not working for me!!!
please guide thanks!!!
app.controller(‘MainController’,
[’$scope’, function($scope) {
$scope.title = ‘My First Angular Program’;
$scope.promo = ‘Let me learn’;
$scope.product = {
name: ‘The Book of Trees’,
price: 19
}
}]);
This works for me just syntax error.
In fact the problem comes from } : the one which has to close the $scope.porduct is the one written near the closing }]); => we don’t need to write it again when we set $scope.product.
Or else it is two of it, and : "There is only enough place for one weird parenthesis in this statement, die ! "( #guns in pockets, sand and dust whispering under the western sun )
Hey there! For me is working just fine!
-
Just copy and paste this code below, in the MainController.
" app.controller(‘MainController’,[’$scope’,function($scope){
$scope.title=‘Top SSSellers in Books’;
$scope.promo =‘Unde vine asta?’;
$scope.product =
{
name: ‘The Book of Trees’,
price: 19
}
}]); " -
And after this, in view = index.html file, put this code in the < / p> tags.:
< p class=“title”>{{product.name}}< /p >
< p class=“price”>{{product.price}}< /p >
“name” and “price” are the proprietys of the object “product”. But you must put the full “p” tags -no spaces between the “<” and the “p” - i can’t because is changing the tags, like you see below :
"{{product.name}}
"
Wow, this helped a ton, thanks!!!
Guys, it’s case sensitive. so make sure to write the sentence exactly as it is.
Yes guyz write a exact sentence which they want…