angularjs - Login application not working -


This is my first application in bronze. I was not sure why this is not working

& lt; Body ng-controller = "login controller" & gt; & Lt; Div name = "sign in" class = "box-content" & gt; & Lt; Div class = "box-top-content" & gt; & Lt; Label & gt; Username: & lt; / Labels & gt; & Lt; Input type = "text" ng-model = "user name" /> gt; & Lt; / Br & gt; & Lt; / Br & gt; & Lt; Label & gt; & Lt; / Labels & gt; Password: & lt; / Labels & gt; & Lt; Input type = "password" ng-model = "password" & gt; & Lt; / Br & gt; & Lt; Button type = "submit" ng-click = "submit ()" & gt; Login & lt; / Button & gt; & Lt; / Div & gt;

My JS is:

  var loginApp = angular.module ('loginapp', []); LoginApp.factory ('authFactory', function) {var authFactory = {}; AuthFactory.login = function (username, password) {if (user name == "ABC" & amp; password == "test") return true; And false return;}; AuthFactory;}); LoginApp.controller ('Login Controller', Function ($ radius, authFactory) {$ scope.submit = function ($ radius, authFactory) {authFactory.login ($ scope.username, $ scope.password). Then (function (status) {If (status) {warning ("welcome");} and {warning ("welcome");}})}};});  

When I click the submit button, nothing happens. No error message what's wrong with this code?

You need to return the object inside the factory:

  LoginApp.factory ('authFactory', function ($ http) {var authFactory = {}; authFactory.login = // ... back authFactory; // it is here});  

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -