>>>and then I tried to debug in VS 2017 but nothing happened at all. My validation code is not firing. Do you see what may be wrong? I did add the js file in the bundle.config.
>>
>>I see that you've got the directive to fire but what is this returning : return services.Item.checkCodeUniqueness(codeObject);
>>Don't forget that this must be promise that will be resolved or rejected.
>
>The Item Service code is this:
>
>
>/**
> * @public
> * @param {object}
> * @returns {ng.IPromise}
> */
> ItemService.prototype.checkCodeUniqueness = function (codeObject) {
> var deferred = services.Deferred;
>
> services.Http.put(urlPath + '/checkCodeUniqueness', codeObject)
> .then(function (data) {
> if (data.data.isValid) {
> deferred.resolve(data.data);
> }
> else
> {
> deferred.reject(data.data.errorMessage);
> }
> });
>
> return deferred.promise;
> };
>
>I haven't have a chance to test it yet and it is still not clear to me how would I assign returned error message to the error to display. I plan to have a few same directives in that form (I need to test both barcode and UPC)
That's returning a promise so should work OK. Maybe the best way to set an error message would be to capture the promise here:
return services.Item.checkCodeUniqueness(codeObject).then( // Get the error message and set it on scope);