Created
June 20, 2015 07:55
-
-
Save stefek99/6b16e7a068a5fdacb674 to your computer and use it in GitHub Desktop.
AngularJS + AngularUI (Bootstrap)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | |
<script src='http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js'></script> | |
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.12.1/ui-bootstrap-tpls.min.js'></script> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<script> | |
var app = angular.module("app", ['ui.bootstrap']); | |
app.controller('ctrl', function ($scope) { | |
$scope.alerts = [ | |
{ type: 'danger', msg: 'Oh snap! Change a few things up and try submitting again.' }, | |
{ type: 'success', msg: 'Well done! You successfully read this important alert message.' } | |
]; | |
$scope.addAlert = function() { | |
$scope.alerts.push({msg: 'Another alert!'}); | |
}; | |
$scope.closeAlert = function(index) { | |
$scope.alerts.splice(index, 1); | |
}; | |
}); | |
</script> | |
</head> | |
<body ng-app="app"> | |
<div ng-controller="ctrl"> | |
<alert ng-repeat="alert in alerts" type="{{alert.type}}" close="closeAlert($index)">{{alert.msg}}</alert> | |
<button class='btn btn-default' ng-click="addAlert()">Add Alert</button> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment