Reputation: 137
I've been trying to change the syntax of Angular so I can use it with Handlebars but it doesn't seem to be working. I think it can see //demo.label//
because it doesn't seem to display it on the webpage, but it doesn't put the sample text inside the label either. Any help on what I've done wrong would be greatly appreciated.
<script>
var customInterpolationApp = angular.module('customInterpolationApp', []);
customInterpolationApp.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('//');
$interpolateProvider.endSymbol('//');
});
customInterpolationApp.controller('DemoController', function() {
this.label = "This binding is brought you by // interpolation symbols.";
});
</script>
<div ng-app="customInterpolationApp" ng-controller="DemoController">
//demo.label//
</div>
Upvotes: 0
Views: 50
Reputation: 3822
You are not using controller as
syntax in html. You have to define alias of your controller as well, like: ng-controller="DemoController as demo"
Demo:
var customInterpolationApp = angular.module('customInterpolationApp', []);
customInterpolationApp.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('//');
$interpolateProvider.endSymbol('//');
});
customInterpolationApp.controller('DemoController', function() {
this.label = "This binding is brought you by // interpolation symbols.";
});
<script src="https://code.angularjs.org/1.5.2/angular.js"></script>
<div ng-app="customInterpolationApp" ng-controller="DemoController as demo">
//demo.label//
</div>
Upvotes: 1