I'm trying to build a simple directive that creates a link on the page to google with dynamic values via the '@' binding strategy, I have it working, but I'm not sure what '@' is doing.
My directive looks like this:
(function() {
var app = angular.module('app', []);
app.directive('myDirective', function() {
return {
restrict: 'A',
replace: true.
scope: {
myUrl: '@', // binding
myLinkText: '@'
},
template: '<a href="{{myUrl}}">{{myLinkText}}</a>'
}
});
})();
And here's my HTML:
<div my-directive
my-url="http://google.com"
my-link-text="Click me to go to Google.">
</div>
How is this different from creating a controller and why do we need to do this in directives? In other words, why do we need to create another scope? I'm not understanding the concept of isolate scope and binding. Thanks for your help.