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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -