Hello AngularJS II

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?

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

Have you used ng-controller=“MainController” for the parent tag.

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

Yes I have exactly

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

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


Try this:

$scope.tyt = ‘Top Sellers in Books’,
$scope.promo = ‘Books’

1 Like

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.';
1 Like

Thanks for help …

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

1 Like

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 }}

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.

I’m facing the same problem

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?

The same problem with me

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