I have been researching how to use ngModel within a custom directive, and while I grasp the concept, I am struggling with implementing it when using $resource.
Currently, I am successfully injecting the "file" scope into my directive and making the API call. However, the value being returned to my server is showing up as null. It seems that my Angular directive implementation may be where the issue lies.
directive.js
angular.module('pro').directive('buyLinkBox', function() {
return {
restrict: "AE",
replace: true,
template: '<md-input-container md-no-float md-block><label style="font-size:2.2vh">Buy Link for {{file.filename}}</label><input type="text" ng-blur="sendLink()" ng-model="file.buyLink" name="buyLink" id="buyLink"/></md-input-container>',
scope: {
file: '=',
},
controller: function($scope, $route ,BuyLinkService){
$scope.sending = BuyLinkService.get({
FileId: $scope.file._id
});
$scope.sendLink = function() {
$scope.sending.$sendLink(function() {
$route.reload();
}, function(errorResponse) {
alert('nope');
});
};
}
}
});
html
<buy-link-box file="file"></buy-link-box>