Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ------------------ ROOTING
- myModule.config(function($routeProvider, $httpProvider){
- $routeProvider.
- when('/',{
- templateUrl: 'home.html',
- controller: 'HomeCtrl',
- controllerAs: 'controller'
- }).
- when('/login',{
- templateUrl: 'login.html',
- controller: 'NavCtrl',
- controllerAs: 'controller'
- }).
- when('/inscription',{
- templateUrl: 'inscription.html',
- controller: 'InscriptionCtrl',
- controllerAs: 'controller'
- }).
- otherwise({
- redirectTo: '/'
- });
- $httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
- });
- -------------------------- CONTROLLER
- myModule.controller('InscriptionCtrl',function($location, $http){
- var self = this;
- self.credentials = {};
- self.register = function(credentials){
- if(credentials != null){
- alert(credentials.username);
- } else{
- alert("credentials is null snif");
- }
- var FormInscriptionDto = credentials ? {login : credentials.username, password : credentials.password} : {};
- $http.post('/register-user', FormInscriptionDto).then(
- function(response){
- alert("wok");
- },
- function(){
- alert("werror");
- }
- );
- };
- });
- ------------------------------- INSCRIPTIOnN.HTML
- <article>
- <div class="alert alert-danger" ng-show="controller.error">
- There was a problem register in. Please try again.
- </div>
- <form role="form" ng-submit="controller.register()">
- <div class="form-group">
- <label for="username">Username:</label>
- <input type="text" class="form-control" id="username" name="username" ng-model="controller.credentials.username"/>
- </div>
- <div class="form-group">
- <label for="password">Password:</label>
- <input type="password" class="form-control" id="password" name="password" ng-model="controller.credentials.password"/>
- </div>
- <button type="submit" class="btn btn-primary">Submit</button>
- </form>
- </article>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement