AngularJS:将模型传入和传出引导UI模式

AngularJS:将模型传入和传出引导UI模式,angularjs,twitter-bootstrap,angular-ui-bootstrap,Angularjs,Twitter Bootstrap,Angular Ui Bootstrap,我的引导UI模式有问题 我有一个从用户那里获取地址细节的模式,但是由于某些原因,这个模型总是空的。我的模板摘录: <form class="form-horizontal" style="padding: 64px;"> <div class="form-group"> <label for="firstName" class="col-sm-3 control-label">First name</label>

我的引导UI模式有问题

我有一个从用户那里获取地址细节的模式,但是由于某些原因,这个模型总是空的。我的模板摘录:

<form class="form-horizontal" style="padding: 64px;">
    <div class="form-group">
        <label for="firstName" class="col-sm-3 control-label">First name</label>
        <div class="col-sm-9">
            <input type="text" class="form-control" id="firstName" ng-model="model.firstName">
        </div>
    </div>
    <div class="form-group">
        <label for="lastName" class="col-sm-3 control-label">Last name</label>
        <div class="col-sm-9">
            <input type="text" class="form-control" id="lastName" ng-model="model.lastName">
        </div>
    </div>
    <!-- etc -->
</form>

名字
姓
和我的控制器:

module Test.Controllers {
    "use strict";

    export class ChooseAddressController {
        static $inject = ["$modal", "AddressService"];

        private addressService: Services.AddressService;

        public addresses: Array<Models.Address>;
        public modal;

        constructor($modal, addressService: Services.AddressService) {
            this.addressService = addressService;
            this.modal = $modal;
        }

        public newAddressClicked(): void {
            var newAddress = this.addressService.createNewAddress();
            this.editAddress(newAddress);
        }

        public editAddress(address: Models.Address): void {
            address.firstName = "Test 1";
            address.lastName = "Test 2";

            var modalInstance = this.modal.open({
                animation: true,
                templateUrl: 'dialogs/editAddressDialog.html',
                backdrop: "static",
                backdropClass: "windowModal",
                keyboard: false,
                resolve: {
                    model: () => address
                }
            });
        }
    }
}
模块测试控制器{
“严格使用”;
导出类ChooseAddressController{
静态$inject=[“$modal”,“AddressService”];
私有地址服务:Services.addressService;
公共地址:数组;
公共模态;
构造函数($modal,addressService:Services.addressService){
this.addressService=addressService;
this.modal=$modal;
}
public newAddressClicked():void{
var newAddress=this.addressService.createNewAddress();
此.editAddress(newAddress);
}
公共编辑地址(地址:Models.address):void{
address.firstName=“测试1”;
address.lastName=“测试2”;
var modalInstance=this.modal.open({
动画:没错,
templateUrl:'dialogs/editAddressDialog.html',
背景:“静态”,
backdropClass:“windowModal”,
键盘:错,
决心:{
型号:()=>地址
}
});
}
}
}
我希望对话框包含“测试1”和“测试2”数据,但它没有。我已经按照建议看过了,但它似乎对我不起作用,这令人沮丧


我做错了什么?

嘿,这是我用来在控制器和模态之间传递数据并返回的方法:

//Inject $modal into your Controller

//Call the modal from your controller


$scope.myModal = function() {
    var modalInstance = $modal.open({
        templateUrl: "some/ur/to/your/template.html",
        controller: "MyModalController",
        size: "lg",
        //Data which has to be passed into the MyModalController
        resolve: {
            data: function () {
                return {                    
                    someData: $scope.someRandomDataWhichModalNeeds
                };
            }
        }
    });

    //When $scope.confirm() is called from inside the modal do some shit with the new data!
    modalInstance.result.then(function (result) {
            console.log(result.modalData)

    });
}

//Handle data insde your modal  
//data param will be your values you need pass in
//If you want add some new data inside your modal just build upon the modalData object

function MyModalController($scope, $modalInstance, data) {

    //assign the data you passed in to the modals scope so you can bind to it
    $scope.modalData = data;
    $scope.result = {
        modalData: $scope.modalData
    }

    //Dismiss() - call this in your modal template to dismiss the modal
    $scope.cancel = function () {
        $modalInstance.dismiss();
    }

    //Call this in your template so send all the modal data back to the controller
    $scope.confirm = function () {
        $modalInstance.close($scope.result);
    }
}


//In your template file you would bind your data:
{{ modalData.someData }}