Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/476.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将数据从ng对话框html传递到控制器_Javascript_Html_Angularjs - Fatal编程技术网

Javascript 将数据从ng对话框html传递到控制器

Javascript 将数据从ng对话框html传递到控制器,javascript,html,angularjs,Javascript,Html,Angularjs,使用ng对话框时遇到一些问题。 当我注意到ngDialog控制器选项时,它会工作。 我可以从中获取$scope.descriptionContext值 <p>Description:</p> <textarea ng-model="descriptionText"></textarea> 并且此值$scope.descriptionText未定义 请帮助我将html元素的值返回到我的控制器或控制器范围 对话框调用代码: $scop

使用ng对话框时遇到一些问题。 当我注意到ngDialog控制器选项时,它会工作。 我可以从中获取
$scope.descriptionContext

<p>Description:</p>
    <textarea ng-model="descriptionText"></textarea>
并且此值
$scope.descriptionText
未定义

请帮助我将html元素的值返回到我的控制器或控制器范围

对话框调用代码:

    $scope.createNewEventModalWindow = function(args)
    {
      $scope.setNewEventField('start', args.start.value);
      $scope.setNewEventField('end', args.end.value);
      ngDialog.open({
          template: 'views/pages/timesheet/template/newEventTemplate.html',
          //controller:'newEventDialogCtrl',
          scope: $scope,
          className: 'ngdialog-theme-default',
          plain: false,
          showClose: true,
          closeByDocument: true,
          closeByEscape: true,
          appendTo: false,
          disableAnimation: false,
          overlay: false
      }).closePromise.then(function(value)
            {
              console.log('Test msg');
              console.log(value);

              var newEvent = {
                start: $scope.getNewEventField('start'),
                end: $scope.getNewEventField('end'),
                text: $scope.descriptionText,
                userID: getCurrentUserID(),
                projectID: $scope.selectedProject,
                taskID: $scope.selectedTask
              };

              console.log('Event data to server');
              console.log(newEvent);
/*
              TimesheetFactory.createEvent(newEvent)
                .success(function(data) {
                    $scope.events = data;
                    $scope.message('Event created');
                    console.log($scope.events);
                })
                .error(function(data) {
                    console.log('Error: ' + data);
                });
*/
            });
    }
对话框的Html模板:

<div class="ngdialog-message">
    <h3>Create Event</h3>
    <p>Project</p>

    <select id='selectProject' ng-model= "selectedProject">
      <option ng-repeat="project in projects" value="{{project.id}}">{{project.name}}</option>
    </select>
    <p>Task</p>
    <select id='selectTask' ng-model="selectedTask">
      <option ng-repeat="task in tasks" value="{{task.id}}">{{task.name}}</option>
    </select>
    <p>Time</p>

    <input type="time" id="eventTime" name="input" ng-model="timeLentgh"/>

    <p>Description:</p>
    <textarea ng-model="descriptionText"></textarea>
</div>
<div class="ngdialog-buttons">
    <button
      type="button"
      class="ngdialog-button ngdialog-button-secondary"
      ng-click="closeThisDialog()"
    >Cancel</button>
    <button
      type="button"
      class="ngdialog-button ngdialog-button-primary"
      ng-click="btnCreateEventClicked()"
    >Create</button>
</div>

创建事件
计划

{{project.name} 任务

{{task.name} 时间

说明:

取消 创造
您可以通过以下方式访问对话框的作用域:

value.$dialog.scope()
其中
value
-从
closePromise
获得的参数

在这个范围内,您将有
descriptionContext

要检查和播放的Plunker:

value.$dialog.scope()