How do you In the controller, attach another property to $scope named product. Set it equal to an object with the following properties:


#1

hello in the controller, attach another property to $scope named product. Set it equal to an object with the following properties: how do you do this?. I would really appreciate some help thank you.


#2

Hi, I had the same problem but I found the solution:

$scope.plusOne =
function(index) {
$scope.products[index].likes += 1;
};


#3

It helps to link to where you are in the course.

@lubi123 That code doesn't relate to his issue. I believe he's on step 1 here.


#4

This step isn't that different from step 2 in the previous exercise (2. Hello AngularJS II). Instead of setting a property to a string, you're setting it to the given object. Let me know if this helps!


#5

Hey man,

so I've typed this..

app.controller('MainController', ['$scope', function($scope) {
  $scope.title = 'Jimmy';
  $scope.promo = ' Ryan';
  $scope.product =  {
    name: 'The book of Trees', 
    price: 19 
  }
                                }]);

Where am I going wrong?


#6

I thinks it's fine, just rerun the code


#7

For anyone having this problem, don't forget that the product name is case-sensitive :

app.controller('MainController', ['$scope', function($scope) {
  $scope.title = 'Jimmy';
  $scope.promo = ' Ryan';
  $scope.product =  {
    name: 'The Book of Trees', 
    price: 19 
  }
 }]);

#8

you just give a semicolon after the end braces following price property.

eg:-
app.controller('MainController', ['$scope', function($scope) {
$scope.title = 'Jimmy';
$scope.promo = ' Ryan';
$scope.product = {
name: 'The Book of Trees',
price: 19
};
}]);


#9

you r ryt u have to use it in index with {{product.name}}