2017-06-08 11 views
1

システムにログインした後、またはパスワードまたはユーザーが間違ってログインに失敗したときに、uikit通知を開始します。私はAngularJSを使用してそれを行うことができると思います。私のプロジェクトでは、ログインしようとすると、まず自分のデータがコントローラに送られ、このデータをdjangoビューに送ります。AngularJSコントローラからUikit通知を起動する方法

login.htmlと

<div class="input" ng-controller="conIngreso"> 

    {% csrf_token %} 

    <div class="login-input-group spacer-field"> 
     <span class="login-input-group-addon"> 
     <i class="fa fa-at fa-fw"></i> 
     </span> 
     <input type="email" class="form-control" name="email" placeholder="Correo electrónico" ng-model="email"> 
    </div> 
    <div class="login-input-group"> 
     <span class="login-input-group-addon"> 
     <i class="fa fa-key fa-fw"></i> 
     </span> 
     <input type="password" class="form-control" name="password" placeholder="Contraseña" ng-model="password"> 
    </div> 

    <button class="btn btn-default btn-lg submit" type="submit" ng-click="ingresar(email, password)">Ingresar</button> 
    </div> 

conIngreso.js conIngreso.jsで

var app = angular.module('appLogin'); 

app.controller('conIngreso', ['$scope', '$http', function($scope, $http){ 
$scope.user={email:'',password:''} 

$scope.ingresar=function(email,password){ 
    $http({method:'POST', 
     url:'/cliente/ingreso/', 
     data:$.param({email: email, password: password}) 
    }).then(
     function(response2){ 
      //UIkit.notification("...", {pos: 'top-right'}); 
      window.location.href='javascript:history.back()'; 
     },function(response2){ 
      $scope.user = response2.data || 'Request failed'; 
     } 
    ); 
} 
}]) 

は私がwindow.locationの前にそれをしようと上...

を提出しないが、仕事

ありがとう

答えて

1

その

UIkit.notify 

、あなたは私がこの UIkit.notificationを使用してい

UIkit.notification 
+0

を使用している({ メッセージ: ":ようこそ<スパン英国・アイコン= 'アイコンがチェック'>を" 、 ステータス: 'success'、 pos: 'トップセンター'、 タイムアウト:5000 }); –

関連する問題