Typescript Angular ui bootstrap modal
Typescript Angular ui bootstrap modal
我使用angular.ui.bootstrap模态来显示模态中的表单。一切都很好,除了当我关闭模态时,我想在父页面上的一个表被更新与模态中添加的新项目。
父控制器:
module MyApp.Controllers {
export interface IController {
items: Models.IItem[];
}
export interface IControllerScope {
}
export class Controller implements IController {
items: Models.IItem[];
constructor(
private $scope: IControllerScope,
private $modal: ng.ui.bootstrap.IModalService) {
}
addItem() {
var options: ng.ui.bootstrap.IModalSettings = {
templateUrl: '/directives/formFirective',
controller: 'formController',
controllerAs: 'modal',
resolve: {
id: () => 1234
}
};
this.$modal.open(options).result
.then(function (item) {
// How do I add item to the instance variable items here?
this.items.push(item) // Does not work here :(
console.log(item)
});
}
}
}
然后在formController中我有:this.$modalInstance.close(item);
我的问题是如何将项目添加到父控制器上的实例变量项目上的模态关闭?
谢谢。
尝试更改=>
function (item) {
// How do I add item to the instance variable items here?
this.items.push(item) // Does not work here :(
console.log(item)
}
在:(item) => {
// How do I add item to the instance variable items here?
this.items.push(item) // Does not work here :(
console.log(item)
}
相关文章:
- 如何在Bootstrap Modal中为动态点击生成的变量设置jade属性
- Jquery and Bootstrap Modal
- 在Java中显示Bootstrap Modal
- 只有当有AJAX响应时,Bootstrap Modal才会出现
- 在Angular Bootstrap Modal和父控制器之间共享作用域
- Bootstrap 3 Modal赢得'从锚标签触发时不会弹出
- Angular 1.5组件中的Angular Bootstrap Modal$uibModalInstance未知提供程
- 修正了在Bootstrap Modal中IE 10与Chrome和Firefox的不同位置
- Bootstrap Modal使背景变黑
- Angular Bootstrap$modal与活动背景元素
- 单击外部时,Twiiter Bootstrap Modal未关闭
- Bootstrap modal赢得't出现
- Jade:在Bootstrap Modal中获取变量
- 正在打开带有锚点标签的Bootstrap Modal
- 如何在Bootstrap 4 Modal中呈现表演动作
- 将函数绑定到Twitter Bootstrap Modal Ajax Complete
- 使用 Codeigniter 和 jquery 在 Modal Bootstrap 3 中的 DB 中填充字段
- Post到CI控制器使用JQueryAjax和Modal Bootstrap
- Modal Bootstrap添加动画
- 从其他html文件打开Modal (bootstrap)