标签: angular-ui-bootstrap

AngularJS UI Bootstrap模式无法从范围执行功能

在我的angularjs应用程序中,我使用UI Bootstrap来创建模态.我将范围和自定义控制器传递给模态,它从原始范围显示我的数据但不能执行任何功能.我有主控制器:

myapp.controller('WsCtrl', function WsCtrl($scope, $location, todoStorage, filterFilter, $modal, $log) {
Run Code Online (Sandbox Code Playgroud)

在控制器我有下一个:

$scope.items = ['item1', 'item2', 'item3'];
$scope.open = function () {
    var modalInstance = $modal.open({
        templateUrl: 'partials/users.html',
        scope: $scope,
        controller: ModalInstanceCtrl,
        resolve: {
            items: function () {
                return $scope.items;
            },
            users: function(){
                return $scope.users;
            },
            CurrentDate: function(){
                return $scope.CurrentDate;
            }
        }
    });

    modalInstance.result.then(function (selectedItem) {
        console.log(selectedItem);
    }, function () {
        $log.info('Modal dismissed at: ' + new Date());
    });
};
Run Code Online (Sandbox Code Playgroud)

而且我在控制器外还有另一个功能:

var ModalInstanceCtrl = function ($scope, $modalInstance, items) {

    $scope.items …
Run Code Online (Sandbox Code Playgroud)

javascript scope twitter-bootstrap angularjs angular-ui-bootstrap

6
推荐指数
2
解决办法
2万
查看次数

一个模态内的datepicker无法正常工作

我正在尝试使用ui-bootstrap组件在模态中创建一个日期选择器.datepicker必须发回格式为unix时间戳的日期.

  1. 如果日期选择器不在模态内(=选择日期时更新时间戳),这工作正常:http://plnkr.co/edit/xQFmVgJojiq6aG9U8f4H? p = preview

  2. 然后,我把指令放在一个模态中:http://plnkr.co/edit/9zHQQPGAcomT5Vha33j3?p = preview

这是控制器:

.controller('MyCtrl', [ '$scope', '$modal', function ($scope, $modal) {
    $scope.open = function () {
        var modalInstance = $modal.open({
            templateUrl: 'tplModal.html',
            controller: 'MyModalCtrl'
        });
    };
}])
.controller('MyModalCtrl', [ '$scope', '$modalInstance', function ($scope, $modalInstance) {
    $scope.required= {};
    $scope.disabled = function(date, mode) {
        return ( mode === 'day' && ( date.getDay() === 0 || date.getDay() === 6 ) );
    };
    $scope.minDate = new Date();
    $scope.$watch('dt', function() { 
        if ($scope.dt) …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui-bootstrap

6
推荐指数
1
解决办法
7883
查看次数

angular-ui-bootstrap手风琴折叠/展开全部

我想为一组手风琴创建一个collpase/expand all按钮.我正在使用angular.js v1.2.6和angular-bootstrap-ui 0.9.0.我无法找到如何进行collpase/expand all的示例.我是一个有角度的新手,任何建议或意见表示赞赏.

另外,我应该补充一点,这篇文章中的解决方案在我使用的较新版本的angular.js(v1.0.8 vs v1.2.6)中不起作用(这是本次发布时的最新版本).在较新的版本中,它会抛出有关尝试创建两个隔离范围的错误.

标记:

    <div ng-controller="myCtlr">

     <accordion close-others="oneAtATime">

     <button class="btn" ng-click="section.isCollapsed = !section.isCollapsed">Toggle Sections</button>

      <accordion-group ng-repeat="section in sections" is-open="section.isOpen">
       <accordion-heading>
        <div class="accordion-heading-content" ng:class="{collapsed: section.isOpen}">
          {{section.name}}
        </div>
       </accordion-heading>
        Section content
      </accordion-group>

     </accordion>

   </div>
Run Code Online (Sandbox Code Playgroud)

JS:

var theapp = angular.module('myApp', [
  'ui.bootstrap'
])

function myCtlr ($scope) {
 $scope.isCollapsed = false;
 $scope.sections = [
    {'id': '353','otherid': '7','name': 'One','Sequence': '1'},
    {'id': '354','otherid': '8','name': 'Two','Sequence': '1'},
    {'id': '355','otherid': '9','name': 'Three','Sequence': '1'}
];

}
Run Code Online (Sandbox Code Playgroud)

accordion angularjs angular-ui-bootstrap

6
推荐指数
2
解决办法
4万
查看次数

如何禁用ui.bootstrap.pagination

我正在使用ui.bootstrap.pagination

我的页面上有一个表单中的搜索框.我想在有人与搜索框交互时禁用分页控件,然后在按下"搜索"后重新启用

我想使用AngularJS表单验证

ng-valid
ng-invalid
ng-pristine
ng-dirty
Run Code Online (Sandbox Code Playgroud)

如何将表单验证与禁用分页联系起来?

我无法找到如何使分页控件显示为禁用和禁用输入.我也在使用Bootstrap 3.

TIA

pagination twitter-bootstrap angularjs angular-ui-bootstrap

6
推荐指数
1
解决办法
3610
查看次数

Angular-ui-bootstrap - 日期选择器 - 如何在弹出窗口中限制对日期选择器的访问?

目前,我可以先选择年份,然后选择月份,然后选择日期.但是,我只需要访问月份和年份.我不知道如何禁用日期选择器选项.

另外,我想在日期选择器中删除所有页脚按钮(今天,清除等).我怎样才能做到这一点?

我正在寻找类似'$ scope.showweeks = false;'的东西.

以下是我的Plunker示例

Plunker-月份选择器

请随时向我索取任何可用的文件.到目前为止,我只能找到

http://angular-ui.github.io/bootstrap/

谢谢

angularjs angular-ui angular-ui-bootstrap

6
推荐指数
1
解决办法
2万
查看次数

在ng-repeat中使用模态窗口

我有一个ng-repeat,我试图添加一个模式,将相同的范围变量传递给模态窗口.我能够打开模态窗口但是ng-repeat的范围值没有显示在模态中.希望我的代码解释得更好.这是我到目前为止:

        <div ng-controller="CustomerController">  
        <div ng-repeat="customer in customers">
               <button class="btn btn-default" ng-click="open()">{{ customer.name }}</button>

                <!--MODAL WINDOW--> 
                <script type="text/ng-template" id="myModalContent.html">
                    <div class="modal-header">
                        <h3>The Customer Name is: {{ customer.name }}</h3>
                    </div>
                    <div class="modal-body">
                            This is where the Customer Details Goes<br />
                            {{ customer.details }}
                    </div>
                    <div class="modal-footer">

                    </div>
                </script>

        </div>  
        </div>
Run Code Online (Sandbox Code Playgroud)

控制器:

   app.controller('CustomerController', function($scope, $timeout, $modal, $log, customerServices) {
    $scope.customers= customerServices.getCustomers();

    // MODAL WINDOW
    $scope.open = function () {

        var modalInstance = $modal.open({
          templateUrl: 'myModalContent.html',
             });

    };

});
Run Code Online (Sandbox Code Playgroud)

以上打开模态窗口.但是,来自ng-repeat的客户详细信息(例如{{customer.name}})不会传递到模态窗口.控制器出了什么问题?

我在这里查看Angular Bootrap …

controller modal-dialog angularjs angularjs-ng-repeat angular-ui-bootstrap

6
推荐指数
1
解决办法
1万
查看次数

Angular - ui-bootstrap - datepicker - 有没有办法检测月份何时发生变化?

我想将日期更改为当前所选月份的第1天.

有没有办法监控月份按钮上的点击事件?

蒂姆萨姆

angularjs angular-ui-bootstrap

6
推荐指数
1
解决办法
4918
查看次数

如何从其他控制器关闭Angular-ui模态

我正在使用Angular-ui弹出一个带有表单的模态.我的代码是:

app.controller('NewCaseModalCtrl', ['$http', '$scope','$modal', function ($http, $scope, $modal, $log) {

  $scope.items = ['item1', 'item2', 'item3'];
  $scope.open = function (size) {

    var modalInstance = $modal.open({
      templateUrl: 'modal-new-case.html',
      controller: 'ModalInstanceCtrl',
      size: size,
      resolve: {
        items: function () {
          return $scope.items;
        }
      }
    });

    modalInstance.result.then(function (selectedItem) {
      $scope.selected = selectedItem;
    }, function () {
    });
  };
}]);
Run Code Online (Sandbox Code Playgroud)

然后我在modal-new-case.html模板中有另一个控制器,我希望它运行一个httpd请求,然后关闭该模块,这是代码:

    app.controller('CreateCaseFormCtrl', ['$http','$scope', function($http,$scope) {
    $scope.formData = {};
    $scope.processForm = function() {

        $http.post('http://api.com/proj', $scope.formData).
        success(function(data, status, headers, config) {
            console.log("success " + data.id);
        }).
        error(function(data, status, …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angular-ui angular-ui-bootstrap

6
推荐指数
1
解决办法
2万
查看次数

Angular UI Bootstrap Popover - 所有打开的popover有多接近

我有一个表格,每个单元格都有一个popover,如下例所示:

对popover的调用:

<td ng-repeat="i in c.installments" ng-class="{ 'first' : i.first, 'last' : i.last, 'advance' : i.advance.value > 0, 'edited' : i.edited, 'final-installment' : i.last }" popover-trigger="{{ popoverFilter(i) }}" popover-placement="top" popover-title="{{i.id == 0 ? 'Advance' : 'Installment ' + i.id}}" popover-append-to-body="true" popover-template="popoverTemplate(i)" ng-init="payment= i; newpayment= i.amount.rounded_value" >
Run Code Online (Sandbox Code Playgroud)

弹出模板:

<script type="text/ng-template" id="editPopoverTemplate.html">
    <form name="editPayment">
      <h2>{{payment.amount.value|currency:undefined:cents}}</h2>
      <div class="form-group" ng-class="{ 'has-error' : editPayment.newpayment.$invalid }">
        <label>New value:</label>
        <input type="number" name="newpayment" ng-model="newpayment" class="form-control no-spinner" step="1" min="10" required>
        <span ng-messages="editPayment.newpayment.$error" class="help-block" role="alert">
          <span ng-message="required">The value is mandatory</span> …
Run Code Online (Sandbox Code Playgroud)

popover angularjs angular-ui-bootstrap

6
推荐指数
1
解决办法
1815
查看次数

使用角度过滤器和分页

我正在对ng-repeat中的项目数组使用过滤器,如下所示:

<input type="text" ng-model="filterText">

<li ng-repeat="item in displayItems | filter : {item_name: filterText}>
Run Code Online (Sandbox Code Playgroud)

这工作正常并完美地过滤项目.问题出现是因为我使用带有uib-pagination元素的displayItems.分页使用totalItems而不是displayItems.

<uib-pagination class="pagination-sm pagination"
    total-items="totalItems.length" ng-model="page" ng-change="changeItems()">
</uib-pagination>
Run Code Online (Sandbox Code Playgroud)

显然我需要以某种方式将过滤器应用于total-items,然后创建displayItems,并将filteredItems放在uib-pagination中.

IE浏览器.当人员键入时,在控制器中将过滤器应用于totalItems,并创建分页所需的filteredItems.然后我还从filteredItems创建displayItems.如何将其放入控制器而不是用于ng-repeat的HTML?

我不知道该怎么做.有什么想法吗?所有人都非常感谢....

我已经包括了一个用来表明它(不是)工作的所有荣耀.... https://plnkr.co/edit/EYX6zO1795sD9TYq2J8U?p=preview

pagination angularjs angular-ui-bootstrap

6
推荐指数
1
解决办法
3万
查看次数