如何以角度方式将数据从组件传递到控制器

时间:2017-11-18 08:27:21

标签: angularjs

我有一个场景,比如我有一个控制器,它有一个控制器,在对话框内我有组件和组件模板有输入框和选择框等更改此输入我想将数据传递给对话框控制器。 请建议我如何实现这一目标。谢谢



<md-dialog flex="30">
  <form name="newContactForm" novalidate layout="column" flex="auto">
    <md-toolbar style="min-height:48px;max-height:48px;" class="md-light md-primary">
      <div class="md-toolbar-tools">
        <h3>{{ContactsDialogCtrl.title}}</h3>
        <span flex></span>
        <md-divider class="vertical-divider" style="background-color: #788395;min-height: 48px;"></md-divider>
        <md-button type="submit" class="md-icon-button" ng-click="createaccountDialogCtrl.createNewContactFn(newContactForm.$valid,newContactForm)">
          <md-icon flex class="icon-custom-position material-icons">save</md-icon>
          <md-tooltip>Save Contact</md-tooltip>
        </md-button>
        <md-divider class="vertical-divider" style="background-color: #788395;min-height: 48px;"></md-divider>
        <md-button class="md-icon-button" ng-click="createaccountDialogCtrl.close()">
          <md-icon class="material-icons">close</md-icon>
        </md-button>
      </div>
    </md-toolbar>
    <md-dialog-content style="padding:20px; overflow-y:auto;height:78vh;" class="overflow-h" layout="row">

      <createaccount-Componentfor-Bidding account-Details="createaccountDialogCtrl.setaccountParameter(event)"></createaccount-Componentfor-Bidding>
    </md-dialog-content>
    </form>
</md-dialog>
&#13;
&#13;
&#13;

enter image description here

&#13;
&#13;
(function() {
    'use strict';

    angular
        .module('webapp')
        .controller('createaccountDialogController', createaccountDialogController);

    /** @ngInject */
    function createaccountDialogController($mdDialog) {
    	var vm = this;
    	vm.state = '';
        vm.close = close;
        vm.setaccountParameter = setaccountParameter;

    	console.log('inside createaccountDialogController');
    	//console.log($state.current.name);
        //getAllbidinformation();
        
        function close() {
            console.log('close');
            $mdDialog.hide();
        };

        function setaccountParameter(obj)
        {
            console.log(obj);
            console.log('inside setaccountParameter');
        }
    }
})();
&#13;
&#13;
&#13;

0 个答案:

没有答案