angularjs - 我如何以 Angular 动态显示我的 Flash 消息。消息必须来自 API 响应

标签 angularjs node.js npm angularjs-directive angular-ui-router

我的即时消息代码如下

<div class="flash-message" ng-if="flash">
<div class="{{'alert alert-' + flash.type}}" ng-bind="flash.message"> 
</div>

现在我正在使用

  FlashService.Success('You have blocked this User');

我想让上面的消息动态化,我现在已经通过了静态。

我的 Node api 现在返回此消息

{
"data": {
    "status": "1",
    "msg": "You have blocked the user"
}
}

最佳答案

将结果传递到函数回调中。

{
"data": {
"status": "1",
"msg": "You have blocked the user"
}
}

输入以下代码以使 Flash 消息动态化。

   FlashService.Success(result.data.msg);

关于angularjs - 我如何以 Angular 动态显示我的 Flash 消息。消息必须来自 API 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50344334/

相关文章:

Node.js SerialPort Arduino 时序问题

node.js - 运行 Node 应用程序时bcrypt无效的elf header

node.js - 如何每次都引用本地安装的Angular2包而不是 "npm install"?

npm - npm install npm -g不会将npm更新到最新版本

html - ngDialog - closeModal 事件 - angularjs

javascript - 评估 Javascript 表达式

javascript - AngularJS 中 module.provider() 的两种不同实现

angularjs - 如何自动使 Angular js 中的本地存储值过期?

javascript - Heroku Node.js 应用程序与 buildpack 不兼容

javascript - 如何更改我自己的库的 index.js 以将其导入为本地对象,而不是全局对象?