2
I’m starting with angular and have a question. I have the following scenario: I created a directive with responsibility to show message on the screen. Below her code.
message js.
"use strict";
angular.module("layout")
.directive('mensagem', function () {
return {
restrict: 'EA',
templateUrl: '/Marcenaria/Scripts/App/Directive/Layout/mensagem.html',
scope:{
msgSucesso: '@',
msgError: '@',
msgInfo: '@'
}
}
});
html message.
<div ng-if="msgSucesso" class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4> <i class="icon fa fa-check"></i> Sucesso!</h4>
{{msgSucesso}}
</div>
<div ng-if="msgError" class="alert alert-warning alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4> <i class="icon fa fa-warning"></i> Atenção!</h4>
{{msgError}}
</div>
<div ng-if="msgInfo" class="alert alert-info alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h4><i class="icon fa fa-info"></i> Informativo!</h4>
{{msgInfo}}
</div>
Call for the directive
<mensagem msgError="{{msgError}}" msgSucesso="{{msgSucesso}}" msgInfo="{{msgInfo}}"></mensagem>
The question is as follows, when I update msgError, for example, this information is not updated within the message directive and therefore does not print the message on the screen, as I resolve ?
alter
@
for=
– Felippe Tadeu
@Felippetadeu, actually your tip helped yes, but I needed to change the name of the attributes of the msgError message directive to error, so I believe I was having trouble recovering the value of the attribute.
– Mayllon Baumer