Definition of promo in coding please

"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. Please im struggling to figure out what they mean by this and what value they are talking about? Would greatly appreciate the help

1 Like

When we say $scope.[something] we are “attaching” a property to $scope. When we attach things to $scope we can use them in the view (the HTML file)


var app = angular.module("myApp", []);
app.controller('MyController', ['$scope', function($scope) { 
  $ = 'Here is my random string';

Within the double curly braces {{promo}} we are accessing the $ value we set in the controller. It should print out “Here is my random string”


<body ng-app="myApp">
     <div ng-controller="MyController">
1 Like

3 posts were split to a new topic: Attaching a new property to scope