How to use Bootstrap alerts using AngularJS

349
November 23, 2016, at 1:44 PM

Hi My project works on Djnago and AngularJS. I want include bootstrap alerts once the user submit. If it is successful show alert-success etc. How can I do this? The following is my angularJS code:

$scope.submit =function(){
    data = {};
    angular.extend(data, $scope.final_data);
    angular.extend(data, { xxx: $scope.final_data.xxx });
    $http.post('{% url 'submission' %}', data).success(
        function(data){
            $scope.get_info();
            alert('DONE!')
        }).error(function(){
            alert('not submitted');
    })
};

Both the alert is working, I want to replace that with bootstrap alerts. How can I do that? Thanks in advance.

Answer 1

Well, you can show/hide alert using ng-show/ng-hide according to error status . I have created a sample plunker.

<alert ng-show='alertType' type="{{alertType}}" close='removeAlert()'>{{alertType}} Alert</alert>
  <select ng-model="alertType">
    <option>danger</option>
    <option>success</option>
    <option>warning</option>
  </select>

This may help you.

Answer 2

Use AngularUI (bootstrap directives for Angular)

https://angular-ui.github.io/bootstrap/#/alert

Rent Charter Buses Company
READ ALSO
Jquery email validation not validate email

Jquery email validation not validate email

I'm using Jquery validation and i tried to implement it, but it's not working on my side. How to fix this?.

372
Randomly check a radio button after a certain time

Randomly check a radio button after a certain time

How do I randomly check a new radio button after a certain time?.

297
Combining elements of 2 dimentional array

Combining elements of 2 dimentional array

I have an JavaScript array:.

330
Google Maps - Dynamically Generating Markers on Map [closed]

Google Maps - Dynamically Generating Markers on Map [closed]

I"m new to google maps and am trying to get all the locations that are returned on my search page to appears on the corresponding map but I can't make it work. I have each listing display their longitude and latitude with the listing and I'm using the code below....

291