AngularJS Flash

https://github.com/wmluke/angular-flash

1. Bower

  "dependencies": {
    "angular-flash": "0.1.14",
  }

2. App.js

var myApp = angular.module('myApp', [
  'angular-flash.flash-alert-directive',
])

myApp.config(function (flashProvider) {
    // Support bootstrap 3.0 "alert-danger" class with error flash types
    flashProvider.successClassnames.push('alert-success');
    flashProvider.infoClassnames.push('alert-info');
    flashProvider.errorClassnames.push('alert-danger');
    flashProvider.warnClassnames.push('alert-warning');
})

3. index.html

    <div flash-alert active-class="in alert" class="alert-flash fade" duration="0">
        <button type="button" class="close" ng-click="hide()">&times;</button>
        <strong class="alert-heading">{{flash.type}}</strong>
        <span class="alert-message">{{flash.message}}</span>
    </div>

...

  <script type="text/javascript" src="bower_components/angular-flash/dist/angular-flash.js"></script>

4. Controller

angular.module('myApp').controller('PartyCtrl', [
...
'flash',
...
function(flash, ...) {
...

    // Clean flash messages when load list view
    // flash.clean(); # TODO: https://github.com/wmluke/angular-flash/pull/36
    flash.info = null;
    flash.success = null;
    flash.error = null;

    // Mostrar un missatgee
    $scope.edit = function (id) {
      flash.info = 'Saved successfully';
    };
]);

AngularJS/Flash (last edited 2015-03-09 15:10:44 by resteve)

Contenidos creados por el equipo de Zikzakmedia. Creative Commons By-NC-SA

PythonZikzakmedia