scalaGirl
scalaGirl

Reputation: 435

Angular: when and why do we need to escape with > and assign with ""?

when and why do we need to escape with > and assign with ""?
Why is image initiated with escaped quotes $scope.image = ""?

 function CarouselController($scope, $timeout) {
  $scope.images = [];
  $scope.image = ""
  $scope.index = 0;

  $scope.setImages = function(images) {
  $scope.images = images;
  $scope.image = images[0];
  $scope.index = 0;
 };

$scope.nextImage = function() {
$scope.index = ($scope.index + 1) % $scope.images.length;
$scope.image = $scope.images[$scope.index];
};

$scope.prevImage = function() {
$scope.index = ($scope.index - 1 >= 0 ? $scope.index - 1 : $scope.images.length    - 1);
$scope.image = $scope.images[$scope.index];
};

var nextImageTimeout = function() {
$scope.nextImage();
$timeout(nextImageTimeout, 5 * 1000);
};

 $timeout(nextImageTimeout, 5 * 1000);
}

src:excellent intro to directives

Upvotes: 1

Views: 154

Answers (1)

Davin Tryon
Davin Tryon

Reputation: 67316

I've never seen this used as a convention, ever. Further, I cannot think of why you would use "" to initialise a controller property. The only thought I did have was that somewhere I'd see a reference to ng-bind-html (so that the directive controller was feeding HTML to the template).

I suspect you are seeing a formatting issue in the blog entry, itself. I think the author has accidentally added unformatted HTML to the example code.

Upvotes: 1

Related Questions