Hello AngularJS II


#1

Likewise, any new properties attached to $scope will become available to use in the view. In the controller, attach promo to $scope, and set its value to your own string.???

This is my code in controller:

app.controller('MainController', ['$scope', function($scope) { 
  $scope.tyt = 'Top Sellers in Books'; 
  $scope.promo = 'Books';
}]);

in view I have:

<h1>{{ tyt }}</h1>
<h2>{{ promo }}</h2>

what is wrong?


#2

Am seeing the same issue anyone knows why it is not working?


#3

Have you used ng-controller="MainController" for the parent tag.
e.g.

<div ng-controller="MainController">
<h1>{{ tyt }}</h1>
<h2>{{ promo }}</h2>
</div>

#4

Yes I have exactly

<div class="main" ng-controller="MainController">
  <div class="container">

   <h1>{{ tyt }}</h1>
  <h2>{{ promo }}</h2>

  </div>
</div>

#5

Try this:

$scope.tyt = 'Top Sellers in Books',
$scope.promo = 'Books'


#6

Thanks, but it does not work.
I try I few times different combinations and next appeared button "Get Code". I clicked it and now work I have:

app.controller('MainController', ['$scope', function($scope) { 
  $scope.title = 'This Month\'s Bestsellers'; 
  $scope.promo = 'The most popular books this month.';
}]);

#7

Thanks for help ....


#8

It works if adding:

  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
  <script src="js/app.js"></script>
  <script src="js/controllers/MainController.js"></script>

to index.html


#9

You don't have to add any extra script.

This is my script

app.controller('MainController', ['$scope', function($scope) {
$scope.title = 'My Books';
$scope.promo = 'These Books are on sale';
$scope.price = 'All Books are $9.99';
}]);

in view:

{{ title }}

{{ promo }}

{{ price }}


#10

I think we'd have to see more code than just what you've linked. My issue so far has been that if I put my code in the wrong place and it doesn't function properly, I still get credit and can move on to the next exercise with broken code.


#11

I'm facing the same problem


#12

I am facing the same issue. It seems that there must be a problem on the Codecademy side. Is there any way to skip this lesson and move on to the next lesson?


#13

The same problem with me


#14

me too, when i wanted to attach the object.
with the given code, i got after a few times of failed submits, i still cant get to the next task.

app.controller('MainController', ['$scope', function($scope) {
$scope.title = 'This Month\'s Bestsellers';
$scope.promo = 'The most popular books this month.';
$scope.product = {
name: 'The Book of Trees',
price: 19
}
}]);


#16