Noufal Noufal - 6 months ago 53
AngularJS Question

GET boolean response through restangular

I have created a rest service using Jersey. The service allows user to check if the username is already available or has been used by someone.

http://localhost:8080/rest/user/checkUname/uname


This returns true or false and it works fine.

Now in my UI I am trying to use the Restangular in Angularjs where my code is as follow

var userBaseUrl = Restangular.all('user');

var valid = userBaseUrl.one('checkUname',uname).get();


But 'valid' does not have a boolean value.

All the executions are working proper as I see in the debugging.

How do I access a boolean response through Restangular ?

Answer

try to do this:

Restangular.all('user').one('checkUname', uname).get().then(
  function (valid) {
    //check here
  }
)