0

Not able to pass phalcon route key to angularjs

Route: //Define a route $router->add( "userList", array( "controller" => "user", "action" => "get", ) );

With in AngularJs: this.getUsers = function() { var defer = $q.defer(); $http.get("userList") .success(function(data) { defer.resolve(data); })
return defer.promise; }
With in angularjs if i pass route value directly like (user/get i.e controllername/action) then everything works fine but if i pass route key(userList) it is showing error as "UserlistController handler class cannot be loaded"

I want to pass route key(userList) not its value(user/get)

Any idea how to do this ?

khanz
  • 205
  • 1
  • 9

1 Answers1

1

In my routes I have a leading slash /

//Define a route
$router->add(
    "/userList",
    array(
        "controller" => "user",
        "action"     => "get",
    )
);

and

$http.get("/userList")

That should work. However if you are creating a new project and don't need to support legacy urls, I would suggest just using the default routes, it is less code so it will be simpler, and might run a little bit faster.

CodeMonkey
  • 3,271
  • 25
  • 50