Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.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
Angularjs 无法在UI引导中更改警报颜色_Angularjs_Twitter Bootstrap 3_Angular Ui Bootstrap - Fatal编程技术网

Angularjs 无法在UI引导中更改警报颜色

Angularjs 无法在UI引导中更改警报颜色,angularjs,twitter-bootstrap-3,angular-ui-bootstrap,Angularjs,Twitter Bootstrap 3,Angular Ui Bootstrap,我正在尝试使用UI引导更改警报的颜色,类似于上的示例。但是当我使用下面的代码时,警报都是警报警告颜色。有没有想过我做错了什么 HTML: 这里有一个您必须从中替换您的类型 <alert ng-repeat="alert in alertForm.alerts" type="{{alertForm.alert.type}}" close="closeAlert($index)" class="text-center">{{alert.msg}}</alert> 有趣的事实

我正在尝试使用UI引导更改警报的颜色,类似于上的示例。但是当我使用下面的代码时,警报都是
警报警告
颜色。有没有想过我做错了什么

HTML:


这里有一个

您必须从中替换您的类型

<alert ng-repeat="alert in alertForm.alerts" type="{{alertForm.alert.type}}" close="closeAlert($index)" class="text-center">{{alert.msg}}</alert>

有趣的事实
alertForm.alerts.$index.type
也可以,但不如使用alert.type。事实上,
alert
等于
alertForm.alerts[$index]
。但是使用后者的可读性要差得多。无论出于什么原因,alert.type没有{{}}在以前的ui引导中工作,但在0.6中没有。请检查此项
.controller('AlertFormCtrl', function(){
   var alertForm = this;
   alertForm.alerts = [

{ type: 'default', msg: 'Please complete the fields below.' },
  { type: 'success', msg: 'Successfully submitted.' }
  ];

alertForm.addAlert = function() {
  alertForm.alerts.push({type: 'danger', msg: 'Another alert!'});
  };

alertForm.closeAlert = function(index) {
  alertForm.alerts.splice(index, 1);
  };
});
<alert ng-repeat="alert in alertForm.alerts" type="{{alertForm.alert.type}}" close="closeAlert($index)" class="text-center">{{alert.msg}}</alert>
<alert ng-repeat="alert in alertForm.alerts" type="{{alert.type}}" close="closeAlert($index)" class="text-center">{{alert.msg}}</alert>