Reputation: 110
<button type="button" class="btn-submit upload smooth-hover" data-prod-idx="{{index}}" data-prod-id="{{prod.ProductId}}"
ng-click="vm.onUpload($event, index, prod.ProductId)"
ngf-select="vm.uploadAttachments($event, $files, $invalidFiles)" multiple accept="image/*,.pdf,*.doc,*.docx" ngf-capture="'camera'"
ngf-max-size="5MB"
ng-disabled="prod.Product_Status === 'Approved||Not Approved'">
Upload Documents</button>
ng-disable
. Its not disabling the button if i give to conditions.2.IF clicked on disabled button it should pop-up the alert message (Not using Jquery) Every condition have different error msg (Conditions in ng-disabled)
Thanks for Help!
Upvotes: 4
Views: 2580
Reputation: 210
Your condition code is wrong
ng-disabled="prod.Product_Status === 'Approved'|| prod.Product_Status === 'Not Approved'"
In case 2, you can remove ng-disable and, on click function, you could made with this way:
function onUpload($event, $files, prod.ProductId){
if(prod.Product_Status === 'Approved'|| prod.Product_Status === 'Not Approved'){
alert("Message")
return;
}
// your code
}
Upvotes: 3
Reputation: 136174
You had wrong expression, it is basically comparing with Approved||Not Approved
as string check. Better you could make use indexOf
valid statuses array to make your implementation more compact.
ng-disabled="prod.Product_Status === isDisabled(prod.Product_Status)"
Code
//later you can add more status here in this array.
var validStatus = ['Approved', 'Not Approved'];
$scope.isDisabled = function isDisabled(product_Status){
return validStatus.indexOf(product_Status) > -1
}
Upvotes: 0
Reputation:
It should be:
ng-disabled="prod.Product_Status === 'Approved' || prod.Product_Status === 'Not Approved'"
Putting the ||
inside the string simply makes it part of the string, not a logical operator.
Upvotes: 1