Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/406.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用AngularJS使用引导警报_Javascript_Jquery_Angularjs_Django_Twitter Bootstrap - Fatal编程技术网

Javascript 如何使用AngularJS使用引导警报

Javascript 如何使用AngularJS使用引导警报,javascript,jquery,angularjs,django,twitter-bootstrap,Javascript,Jquery,Angularjs,Django,Twitter Bootstrap,嗨,我的项目在Djnago和AngularJS上工作。我希望在用户提交后包含引导警报。如果成功,则显示警报成功等。我如何才能做到这一点? 以下是我的angularJS代码: $scope.submit =function(){ data = {}; angular.extend(data, $scope.final_data); angular.extend(data, { xxx: $scope.final_data.xxx }); $http.post('{%

嗨,我的项目在Djnago和AngularJS上工作。我希望在用户提交后包含引导警报。如果成功,则显示警报成功等。我如何才能做到这一点? 以下是我的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');
    })
};
这两个警报都正常工作,我想用引导警报替换它。我该怎么做?提前感谢。

使用AngularUI(AngularUI的引导指令)


您可以根据错误状态使用ng show/ng hide显示/隐藏警报。我创造了一个新的世界

{{alertType}}Alert
危险
成功
警告

这可能会对您有所帮助。

请查看此软件包并添加您的意见


警觉的

以下是我使用的解决方法

查看文件:

<div class="alert alert-{{ResponseModel.ResponseType}}" alert-dismissible ng-show="ResponseModel.ResponseAlert">
<a href="#" class="close" ng-click="ResponseModel.ResponseAlert = false" aria-label="close">&times;</a>
<strong> {{ResponseModel.ResponseMessage}} </strong>
</div>

我搜索并获取此自定义指令。你可以用这个。嗨,Jigs,我很困惑在这个场景中我怎么能用这个。我不明白为什么控制器后面会有一个列表,或者我没有用过那个模块。您可以使用引导警报。好的,请看我的答案作为示例。嗨,我知道这一点。但是我怎么能把这个应用到我的angularJS部分呢?@Hema CDN不起作用。谢谢提醒。现在可以用了,但有点过时了。
<button lg-alert="[scope-function]" lg-size="[size of the modal]" lg-type="[type]" lg-message="[message need to be displayed in the alert">
    Alert 
</button>
<div class="alert alert-{{ResponseModel.ResponseType}}" alert-dismissible ng-show="ResponseModel.ResponseAlert">
<a href="#" class="close" ng-click="ResponseModel.ResponseAlert = false" aria-label="close">&times;</a>
<strong> {{ResponseModel.ResponseMessage}} </strong>
</div>
Controller File:

$scope.ResponseModel = {};
$scope.ResponseModel.ResponseAlert = true;
$scope.ResponseModel.ResponseType = "danger";
$scope.ResponseModel.ResponseMessage = "Message to be displayed!!"