Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.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 ngDialog中的UI引导日期选择器不';T_Javascript_Angularjs_Twitter Bootstrap_Datepicker - Fatal编程技术网

Javascript ngDialog中的UI引导日期选择器不';T

Javascript ngDialog中的UI引导日期选择器不';T,javascript,angularjs,twitter-bootstrap,datepicker,Javascript,Angularjs,Twitter Bootstrap,Datepicker,我试图在ngDialog中使用ui引导日期选择器,但我只能打开它一次。当我选择日期时,选择器关闭,我无法再打开它。 见普朗克: index.html: <!DOCTYPE html> <html ng-app="plunker"> <head> <meta charset="utf-8" /> <title>AngularJS Plunker</title> <script src="https://aj

我试图在ngDialog中使用ui引导日期选择器,但我只能打开它一次。当我选择日期时,选择器关闭,我无法再打开它。 见普朗克:

index.html:

<!DOCTYPE html>
<html ng-app="plunker">

<head>
  <meta charset="utf-8" />
  <title>AngularJS Plunker</title>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.4.0/js/ngDialog.min.js"></script>
  <script src="ui-bootstrap-tpls-0.14.3.min.js" type="text/javascript"></script>
  <script src="app.js"></script>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.4.0/css/ngDialog.min.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.4.0/css/ngDialog-theme-default.min.css" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" />
</head>

<body ng-controller="MainCtrl">
  <button ng-click="showCreateOrderPopup()">Create order</button>
</body>

</html>
弹出窗口:

<form name="createOrderForm">
  <div class="row">
    <div class="form-group">
      <label for="createOrderStart">Start Time</label>
      <div>
        <div ng-class="{'has-error' : createOrderForm.createOrderStart.$error.required}">
          <div class="input-group">
            <input ng-model="createOrder.startTime" type="text" class="form-control" id="createOrderStart" name="createOrderStart" uib-datepicker-popup="shortDate" is-open="openedCreate" datepicker-options="dateOptions" current-text="Today" required clear-text="Clear"
            close-text="Close" ng-readonly="false" />
            <span class="input-group-btn">
            <button type="button" class="btn btn-primary" ng-click="openDatePickerCreate($event)">Cal</button>
            </span>
          </div>
        </div>
      </div>
    </div>
  </div>
</form>

开始时间
卡尔
奇怪的是,当我动态添加datepicker(使用ngRepeat)时,一切都很好

有没有办法让这一切顺利进行?
提前谢谢。

对不起,我刚意识到你在说什么

将代码更改为以下内容:

$scope.status= {opened: false}
$scope.openDatePickerCreate = function ($event) {
    $scope.status.opened = true;
};
is-open="status.opened"
另外,将html更改为以下内容:

$scope.status= {opened: false}
$scope.openDatePickerCreate = function ($event) {
    $scope.status.opened = true;
};
is-open="status.opened"

所有这些都是因为原型继承。你可能想对此进行研究。

太好了,这很有效。为什么将其存储在数组和简单变量中有区别?但无论如何,非常感谢。这与原始变量和原型继承有关。请看一下:大多数情况下,我在作用域内创建对象是为了存储基本值“$scope.view={}”,甚至是其他对象,以避免这个问题。非常感谢,我会看一看。