I'm taking a course on AngularJS on Coursera.
The code that the instructor demonstrated in the videos works but for some reason I couldn't get to run on my environment:
Page Layout (partial):
<div class="media-body"> <h2 class="media-heading">{{dish.name}} <span class="label label-danger">{{dish.label}}</span> <span class="badge">{{dish.price | currency}}</span></h2> <p>{{dish.description}}</p> </div> Snippet A (demonstrated by professor that I couldn't get to work):
var app = angular.module('confusionApp',[]); app.controller('dishDetailController', function() { var dish={ //attributes here; }; this.dish = dish; }); When I would run this function, I don't get any errors in the console but I don't get anything in the display.
Snippet B:
var app = angular.module('confusionApp',[]); app.controller('dishDetailController', function($scope) { var dish={ //attributes here;}; $scope.dish = dish; }); When I do it this way, it works. Is there a difference?
$scope.<etc>view. It is a mere difference ofcontroller as vs $scope