您好,我的项目适用于 Djnago 和 AngularJS。我想在用户提交后包含 Bootstrap 警报。如果成功显示警报成功等。我该怎么做? 以下是我的 angularJS 代码:
$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');
})
};
两个警报都有效,我想用 Bootstrap 警报替换它。我怎样才能做到这一点?提前致谢。
最佳答案
好吧,您可以根据错误状态使用 ng-show/ng-hide 显示/隐藏警报。我创建了一个 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>
这可能对你有帮助。
关于javascript - 如何使用 AngularJS 使用 Bootstrap 警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33337750/