I have my custom directive to upload file like this in parent HTML
<uploading-multiple-files controlmodel="serviceProfile.serviceProfileAttachments"
upload-all-action="uploadAll" delete-action="deleteImage"
attachment-type-id="scopeTypeId" url="scopeUrl" enable-upload="enableUpload">
</uploading-multiple-files>
In parent controller the code for deleteAction is
$scope.deleteImage = function (attachment) {
alert(attachment.id);
}
my uploadAllAction is working now I want to implement deleteAction in a similar way here is its implementation
function uploadingMultipleFiles(FileUploader, $rootScope, $http, $filter, $window, browser) {
return {
replace: false,
scope: {
'attachmentTypeId': '=?',
'controlmodel': '=',
'url': '=',
'maxsize': '=?',
'uploadAllAction': '=?',
'deleteAction': '=?',
"counter": '=?',
"enableUpload": '=?',
"isRequired": '=?'
},
templateUrl: '/app/views/Controls/UploadingMultipleFilesDirective/UploadingMultipleFilesDirectiveTemplate.html',
link: link
};
Now I want to initialize my method
<div class="col-md-6" ng-repeat="item in controlmodelFiltered">
<div class="col-md-12">
<button class="info" ng-click="delete(item)">x</button>
</div>
</div>
So ng-click="delete(item)" in directive used to initialize the deleteAction
scope.delete = function (attachment) {
debugger;
scope.deleteAction(attachment); //error delete action is not defined
}
when I click delete button the directive js initialize the deleteAction with attachment and it should call controller method then defined in directive but I get the error
TypeError: scope.deleteAction is not a function
deleteActionmethod'=', binding in components. Instead use one-way,'<', binding for inputs and use expression,'&', binding for outputs. It will make the transition to Angular 2+ easier. For more information, see AngularJS Developer Guide - Component-based Application Architechture.