Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.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
Angularjs 角度日期选择器引导ui在视图中不工作_Angularjs_Angularjs Scope_Angular Ui - Fatal编程技术网

Angularjs 角度日期选择器引导ui在视图中不工作

Angularjs 角度日期选择器引导ui在视图中不工作,angularjs,angularjs-scope,angular-ui,Angularjs,Angularjs Scope,Angular Ui,我使用AngularUI团队用纯AngularJS编写的引导组件 问题是内部视图日期选择器不能正常工作。 因此,我有以下代码: <input type="text" datepicker-popup="{{format}}" ng-model="datepicker" show-weeks="fasle" is-open="opened" /> <button class="btn" ng-click="open(

我使用AngularUI团队用纯AngularJS编写的引导组件

问题是内部视图日期选择器不能正常工作。 因此,我有以下代码:

<input type="text" 
       datepicker-popup="{{format}}" 
       ng-model="datepicker"
       show-weeks="fasle" 
       is-open="opened"
 />
<button class="btn" ng-click="open()"><i class="icon-calendar"></i></button>
scope.opened store true中 第二个问题是我试图从日期选择器中检索日期。初始化时,我使用下一步:

scope.datepicker = new Date();
scope.format = "dd-MM-yyyy";
取回

scope.save = function() {
 console.log(scope.datepicker);
};
日期选择器始终返回当前日期

但从侧面看,一切都很完美!为什么? 编辑

这是现场直播


尝试更改日期,然后单击“保存”。或者尝试通过单击按钮呼叫dapicker,将控制器添加到路由Provider中

angular.module('plunker', ['ui.bootstrap'])
  .config(function ($routeProvider) {
        $routeProvider
            .when('/', {
                templateUrl: 'template.html',
                controller: 'DatepickerDemoCtrl'
            })
    });
演示

HTML

<div class="form-horizontal">
        <input type="text" 
          datepicker-popup="dd-MMMM-yyyy" 
          ng-model="dt" is-open="opened" 
          min="minDate"
          max="'2015-06-22'" 
          datepicker-options="dateOptions" 
          date-disabled="disabled(date, mode)" 
          ng-required="true"
          />
        <button class="btn" ng-click="open()"><i class="icon-calendar"></i></button>
    </div>

将控制器添加到路由Provider:

angular.module('plunker', ['ui.bootstrap'])
  .config(function ($routeProvider) {
        $routeProvider
            .when('/', {
                templateUrl: 'template.html',
                controller: 'DatepickerDemoCtrl'
            })
    });
演示

HTML

<div class="form-horizontal">
        <input type="text" 
          datepicker-popup="dd-MMMM-yyyy" 
          ng-model="dt" is-open="opened" 
          min="minDate"
          max="'2015-06-22'" 
          datepicker-options="dateOptions" 
          date-disabled="disabled(date, mode)" 
          ng-required="true"
          />
        <button class="btn" ng-click="open()"><i class="icon-calendar"></i></button>
    </div>

谢谢你的回答,但在我的情况下,我与gn视图工作。并使用routing加载模板。将实时演示添加到我的问题底部将控制器添加到routeProvider,修复您的抢掠并编辑我的回答这听起来像一个解决方案。但是,在这种情况下,控制器将加载两次。最好的解决方案是在deffrent文件中分离逻辑?仅在路由器的配置中加载控制器,在html的头中不加载控制器?另请注意,在不向路由添加控制器的情况下,我可以访问此控制器的范围。为什么?请回答Thx,但在我的情况下,我使用gn view。并使用routing加载模板。将实时演示添加到我的问题底部将控制器添加到routeProvider,修复您的抢掠并编辑我的回答这听起来像一个解决方案。但是,在这种情况下,控制器将加载两次。最好的解决方案是在deffrent文件中分离逻辑?仅在路由器的配置中加载控制器,在html的头中不加载控制器?注意,但在不向路线添加控制器的情况下,我可以访问此控制器的范围,为什么?