AngularJS - ng-switch and primitive
by darul75
HTML
<div ng-controller="Controller">
<directive info="naomi">
this is the name of {{naomi.name}}
</directive>
<button ng-click="test()">change</button>
</div>
JavaScript
var app = angular.module('myApp', [])
.controller('Controller', ['$scope', function(scope) {
scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' };
scope.test = function() {
scope.naomi = {
name: 'Clarrisse',
address: '1600 Amphitheatre'
};
};
console.log(scope);
}])
.directive('directive', function() {
return {
scope: {
customerInfo: '=info'
},
restrict: 'E',
transclude: true,
template: '<div ng-transclude></div>',
link: function (scope, element) {
console.log(scope);
}
};
});