javascript - AngularJS Simple Login -
i'm newbie angularjs , have little knowledge of javascript.
i'm trying implement login page have url server (http://somerandomip/user/get?p=retail123&username=retail123)
give me json response dummy data upon successful login.
if username or password invalid, json response returned have error message in it.
i've tried looking tutorials in simple way possible can't seem figure out how use $http done. understand pretty n00b question lack of javascript knowledge doesn't help.
if direct me towards basic demo of how done, i'd appreciate lot. in advance.
edit: understand sending password not safe, i'm trying working login first.
firstly need inject dependency
use $http
-
myapp.controller("myctrl", function($scope, $http){ ...... })
then send data via post
-
var data = { username: username, password: password };
then can post
data url -
$http.post("/api/login", data).then(function(response){ if (response.data) { // use accordingly data console.log(respose.data); } else { ...... } })
for more information - angular $http docs
as tip, explore more services in angularjs.
Comments
Post a Comment