AngularJS - ng-switch and primitive
by darul75
HTML
<div ng-controller="Controller">
<directive></directive>
<button ng-click="test()">change</button>
</div>
JavaScript
var app = angular.module('myApp', [])
.controller('Controller', ['$scope', function(scope) {
scope.customer = {
name: 'Naomi',
address: '1600 Amphitheatre'
};
scope.test = function() {
scope.customer = {
name: 'Clarrisse',
address: '1600 Amphitheatre'
};
};
}])
.directive('directive', function() {
return {
// scope = false, we inherit from controller one
restrict: 'E',
template: 'Name: {{customer.name}} Address: {{customer.address}}'
};
});