私はfirebaseを持つ単純なアプリを持っています。 firebaseデータベースにはいくつかのデータを保存し、保存した後、 "everythig is great"または "bad"というレスポンスで警告ウィンドウを表示したい。 ui-bootstrapを使用している警告ウィンドウ用。 $ rootScopeを使ってアラートを出します。私はいくつかのデータを保存したときに、私は、コールバックを持っている:
<div uib-alert
ng-class="'alert-' + (alert.type || 'warning')"
dismiss-on-timeout="2000"
ng-if="showAlert"
close="close()">{{alert.msg}}
</div>
<button ng-click='press()'>Press</button>
とコントローラが工場を呼び出します:
person.child(someName)
.set(personData)
.then(function() {
$rootScope.alert = {type:'success', msg:'Person is added!'};
$rootScope.showAlert = true;
console.log($rootScope.showAlert, $rootScope.alert);
})
.catch(function (e) {
$rootScope.alert = {type:'danger', msg:e};
$rootScope.showAlert = true;
});
htmlがある
私はrootScopeをするための設定値であることがわかりコンソールで$scope.press = function() {
fact.setItem({name: 'Josh', age: 20, sex: 'male'});
}
アラートとshowAlertが表示されますが、アラートは機能していないので、この2つの値をhtmlページにバインドして、最初のボタンが機能していないことを確認していますが、2番目は動作しています。In jsbin example I make this situation。私がこの状況で間違っている場所?
THXは、それが動作!私は$適用を忘れて、数日間は何が間違っているか理解できません:) – YoroDiallo