Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var init = function () {
- $http({
- method: 'GET',
- url: 'http://localhost/hrm/public/getUsers'
- }).success(function (data) {
- angular.forEach(data, function(item){
- console.log(item);
- $scope.users.push(item);
- });
- }).error(function (data) {
- console.log(data);
- }); };
- init();
- $scope.addUser = function (event) {
- $mdDialog.show({
- controller: DialogController,
- parent: angular.element(document.body),
- templateUrl: 'views/admin/addUser.html',
- controllerAs: 'ctrl',
- clickOutsideToClose:true,
- targetEvent: event
- }).then(function (addUser) {
- $mdToast.show(
- $mdToast.simple()
- .textContent("User ajouté avec succès")
- .position('top right')
- .hideDelay(1500)
- );
- }, function(cancel) {
- });
- };
- $scope.addUser = function () {
- if($scope.password == $scope.cpassword){
- $http({
- method: 'POST',
- url: 'http://localhost/hrm/public/saveUser',
- data: {email: $scope.email,password: $scope.password}
- }).success(function (data) {
- $http({
- method: 'POST',
- url: 'http://localhost/hrm/public/assign-role',
- data: {email: $scope.email, name: $scope.selectedItem}
- }).success(function (data) {
- $scope.users.push(data);
- console.log(data);
- });
- });
- }
- else {
- console.log("password error");
- }
- $mdDialog.hide();
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement