Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form ng-submit="ctrl.loginUser()" name="myLoginForm">
- <div class="form-group">
- <label>Username</label>
- <input type="text" name="uname" class="form-control" ng-model="ctrl.loginuser.username" required>
- </div>
- <div class="form-group">
- <label>Password</label>
- <input type="password" name="pwd" class="form-control" ng-model="ctrl.loginuser.password" required>
- </div>
- <input type="submit" value="Login">
- </form>
- angular.module("BaseApp", [])
- .config(['$httpProvider', function($httpProvider) {
- $httpProvider.defaults.xsrfCookieName = 'csrftoken';
- $httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
- }])
- .config(['$locationProvider', function($locationProvider){
- $locationProvider.html5Mode(true);
- }])
- self.loginUser = function(loginuser) {
- return $http.post("/custom-api-auth/login", loginuser)
- .then(function(response) {
- console.log('here');
- $location.url("/test");
- });
- };
- $stateProvider.state('test', {
- resolve:{
- // Example using function with simple return value.
- // Since it's not a promise, it resolves immediately.
- simpleObj: function(){
- return {value: 'simple!'};
- },
- // Example using function with returned promise.
- // This is the typical use case of resolve.
- // You need to inject any services that you are
- // using, e.g. $http in this example
- promiseObj: function($http){
- // $http returns a promise for the url data
- return $http({method: 'GET', url: '/someUrl'});
- },
- },
Advertisement
Add Comment
Please, Sign In to add comment