I have a controller with method that gets a parameter, and I want a directive to call that method and pass the parameter.
how do I add a tag to the controller when a user clicks a tag inside the directive.
a bit of code:
app.controller('MainCtrl', function($scope) {
$scope.chosenTags = ['clickToRemoveMe', 'if you click on tags below they should appear here'];
$scope.jokes = [{
id: 0,
content: 'bla bla bla bla',
tags: ['fat', 'blondes']
},{
id: 1,
content: 'another another another ',
tags: ['thin', 'dark']
}];
$scope.addTag = function(tag) {
$scope.chosenTags.push(tag);
},
$scope.removeTag = function(tag) {
removeA($scope.chosenTags, tag);
}
});
app.directive("joke", [function () {
return {
restrict: 'E',
templateUrl: 'joke.html',
scope: {
joke: '='
}
};
}]);
plunker: http://plnkr.co/edit/Vpip4mWmWeH8Lvi7I5t5?p=preview