标签: angular-ui-bootstrap

Angular UI Bootstrap响应Navbar下拉列表在新版本中无法正常工作

我刚AngularJS用grunt bower和创建了一个项目Yeoman.包含更新版本Angular 1.3.13.我想使用Angular UIbootstrap.我添加了响应的Nav Bar.但是在小屏幕上,下拉似乎不起作用.当我点击下拉列表时,整个菜单会隐藏.

这是我的index.html

<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css(.) styles/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- build:css(.tmp) styles/main.css -->
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
</head>
<body ng-app="webClientApp">
    <!--[if lt IE 7]>
      <p class="browsehappy">You are using an …
Run Code Online (Sandbox Code Playgroud)

nav angularjs angular-ui-bootstrap

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

AngularUI-Bootstrap的Typeahead无法读取`undefined`的`length`属性

当我尝试使用promise从AngularUI-Bootstrap获取一个typeahead值时,我收到以下错误.

TypeError: Cannot read property 'length' of undefined
  at http://localhost:8000/static/js/ui-bootstrap-tpls-0.6.0.min.js:1:37982
  at i (http://localhost:8000/static/js/angular.min.js:79:437)
  at i (http://localhost:8000/static/js/angular.min.js:79:437)
  at http://localhost:8000/static/js/angular.min.js:80:485
  at Object.e.$eval (http://localhost:8000/static/js/angular.min.js:92:272)
  at Object.e.$digest (http://localhost:8000/static/js/angular.min.js:90:142)
  at Object.e.$apply (http://localhost:8000/static/js/angular.min.js:92:431)
  at HTMLInputElement.Va.i (http://localhost:8000/static/js/angular.min.js:120:156)
  at HTMLInputElement.x.event.dispatch (http://localhost:8000/static/js/jquery-1.10.2.min.js:5:14129)
  at HTMLInputElement.v.handle (http://localhost:8000/static/js/jquery-1.10.2.min.js:5:10866) 
Run Code Online (Sandbox Code Playgroud)

我的HTML标记是:

<input type="text" class="form-control" id="guestName" ng-model="name" typeahead="name for name in getTypeaheadValues($viewValue)">
Run Code Online (Sandbox Code Playgroud)

我的getTypeaheadValues功能执行以下操作:

$scope.getTypeaheadValues = function($viewValue)
{
    // return ['1','2','3','4'];

    $http({
        method: 'GET',
        url: 'api/v1/person?name__icontains=' + $viewValue
    }).error(function ($data) {
        console.log("failed to fetch typeahead data");
    }).success(function ($data) {
        var output = [];
        $data.objects.forEach(function …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angular-ui angular-ui-bootstrap

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

尽管看似正确的呼叫,角度自举模式对话框也不会显示

我试图从角度控制器调用模态对话框.这个例子非常简单,距离非常简单.我有代码如

$modal.open({
        template: '<div class="modal-body">Choose current project<button class="btn btn-primary" ng-click="ok()">OK</button> <button class="btn btn-warning" ng-click="cancel()">Cancel</button></div>',
        controller: ModalChooseProjectCtrl
    });
Run Code Online (Sandbox Code Playgroud)

控制功能声明为

var ModalChooseProjectCtrl = function($scope, $modalInstance) { 
         $scope.ok = function() {
        $modalInstance.close($scope.chosenProject);
    };

    $scope.cancel = function() {
        $modalInstance.dismiss('cancel');
    };
};
Run Code Online (Sandbox Code Playgroud)

它是从一个属于div的控制器函数调用的,它包含bootstrap的navbar.

问题:当我调用具有$ modal.open调用的函数时,会显示错误

  Error: [$compile:tplrt] Template for directive 'modalBackdrop' must have exactly one root element. template/modal/backdrop.html 
  http://errors.angularjs.org/1.2.15-build.2378+sha.9335378/$compile/tplrt?p0=modalBackdrop&p1=template%2Fmodal%2Fbackdrop.html


  Error: [$compile:tplrt] Template for directive 'modalWindow' must have exactly one root element. template/modal/window.html
  http://errors.angularjs.org/1.2.15-build.2378+sha.9335378/$compile/tplrt?p0=modalWindow&p1=template%2Fmodal%2Fwindow.html
Run Code Online (Sandbox Code Playgroud)

这些错误说模板,可以这么说,mut包含在一个html根元素中,这从模板中可以明显看出来.另外,在调用之后,我看到代码中出现了以下元素

 <div modal-backdrop="" class="ng-scope"></div>
 <div modal-window="" index="0" animate="animate" class="ng-scope"></div>
Run Code Online (Sandbox Code Playgroud)

如果我进一步点击,代码中会出现更多的模态窗口.但屏幕只是跳跃而没有任何反应,我没有得到我的模态对话框.在Plunker中,对话框的调用代码显示它很好(http://plnkr.co/edit/VJ1Kick7QWE3X0bL6gtw,但它只是基本的调用例程.)

javascript twitter-bootstrap angularjs angular-ui-bootstrap

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

angular-ui datepicker datepicker的初始状态未按datepicker-popup格式化

我正在使用angular-ui datepicker,除了datepicker的初始状态之外,一切都工作正常.我选择约会后,看起来很好.见下文:

初始状态

在此输入图像描述

在选择器中选择日期后

在此输入图像描述

所以,显然我在第一种情况下获得了日期对象的严格版本,并在选择日期后进行了格式化.

标记

<input type="text" class="form-control"
       id="birthday"
       datepicker-options="datePickerOptions"
       datepicker-popup="{{format}}"
       data-ng-model="birthday"
       data-is-open="opened"
       data-ng-required="true"
       data-close-text="Close"/>

<span class="input-group-btn">
    <button type="button"
            class="btn btn-default"
            data-ng-click="open($event)">
        <i class="fa fa-calendar"></i>
    </button>
</span>
Run Code Online (Sandbox Code Playgroud)

控制器

var today = $scope.today = function today() {
    $scope.birthday = $scope.client.birthday || new Date();
};
today();

$scope.clear = function clear() {
    $scope.dt = null;
};

$scope.open = function($event) {
    $event.preventDefault();
    $event.stopPropagation();

    $scope.opened = true;
};

$scope.format = 'MMM d, yyyy';
$scope.datePickerOptions = {
    'show-weeks': false
};
Run Code Online (Sandbox Code Playgroud)

这不是一个大问题,但如果模型(需要是每个文档的日期对象)按照$scope.format开头的格式而不是格式化的日期对象,那将会非常好.此外,不确定它是否有所作为,但这个日期选择器在一个模态内.谢谢你的帮助!

UPDATE

看起来我不是唯一遇到这种情况的人,而且它与使用角度1.3有关. …

datepicker angularjs angular-ui-bootstrap

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

UI Bootstrap Popover:更改宽度

我正在尝试使用AngularJS中UI Bootstrap的popovers:http://angular-ui.github.io/bootstrap/#/popover

<i class="fa fa-question-circle" popover="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur porta libero tincidunt, malesuada tellus vitae, dapibus ex. Ut tristique tristique eros." popover-trigger="mouseenter" popover-placement="right"></i>
Run Code Online (Sandbox Code Playgroud)

它给了我一个像这样的popover:

在此输入图像描述

我怎样才能改变这个popover的宽度?

angularjs angular-ui-bootstrap

18
推荐指数
4
解决办法
3万
查看次数

Angular-UI $对话框和表单在回车键上提交

从我所看到的,在AngularJS中处理对话框中的输入键的推荐方法是在对话框中放置一个<form>标签和一个提交按钮.

很公平,但如果您使用Angular-UI及其$ dialog服务,则在按Enter键时,表单将以静默方式关闭.没办法拦截那个.即使您将处理程序附加到ng-click或ng-submit,表单也会关闭而不返回任何结果.

我还需要做些什么

[编辑]

解决了它,我必须明确指出我的"取消"按钮是"按钮"类型.好像它默认为"提交"?

所以除了我的html表单技巧之外没有真正的问题:)

angularjs angular-ui angular-ui-bootstrap

17
推荐指数
1
解决办法
7350
查看次数

停止在jQuery单击事件中传播底层ng-click

Twitter Bootstrap dropdown嵌套在一个tr.在tr通过可点击ng-click.单击页面上的任意位置将折叠下拉菜单.该行为在指令中定义$document.bind('click', closeMenu).

因此,当菜单打开,并且用户单击一行时,我希望菜单关闭(就像它一样)并且我想阻止该行上的click事件.

JSFiddle:http://jsfiddle.net/LMc2f/1/
JSFiddle +指令内联:http://jsfiddle.net/9DM8U/1/

来自ui-bootstrap-tpls-0.10.0.js的相关代码:

angular.module('ui.bootstrap.dropdownToggle', []).directive('dropdownToggle', ['$document', '$location', function ($document, $location) {
  var openElement = null,
      closeMenu   = angular.noop;
  return {
    restrict: 'CA',
    link: function(scope, element, attrs) {
      scope.$watch('$location.path', function() { closeMenu(); });
      element.parent().bind('click', function() { closeMenu(); });
      element.bind('click', function (event) {

        var elementWasOpen = (element === openElement);

        event.preventDefault();
        event.stopPropagation();

        if (!!openElement) {
          closeMenu();
        }

        if (!elementWasOpen && !element.hasClass('disabled') …
Run Code Online (Sandbox Code Playgroud)

jquery twitter-bootstrap angularjs angular-ui-bootstrap angularjs-ng-click

17
推荐指数
3
解决办法
4万
查看次数

全局配置Angular指令

一些Angular UI Bootstrap指令(例如datepicker)具有如下配置指令:"所有设置都可以作为属性提供,也可以<datepicker>通过全局配置datepickerConfig."

虽然列出了配置选项,但没有描述我是什么*Config以及如何全局配置一个.听起来这是Angular的标准部分.是吗?我如何使用此配置模式,以及它在哪里记录?

configuration angularjs angular-ui-bootstrap

17
推荐指数
1
解决办法
4442
查看次数

Angular UI Bootstrap中的分页抛出"错误:[$ compile:nonassign]"

我正在使用Angular Bootstrap UI的分页指令的相当简单的实现,但我一直得到一个我无法弄清楚的错误.这是相关的片段:

<ul>
  <li ng-repeat="todo in filteredIdeas">
    {{todo}}
  </li>
</ul>
<pagination ng-model="currentPage" total-items="totalIdeas"></pagination>
Run Code Online (Sandbox Code Playgroud)

以下是控制器中$ scope的相关部分:

// Set watch on pagination numbers
$scope.$watch('currentPage + numPerPage', function() {

  var begin = (($scope.currentPage - 1) * $scope.numPerPage);
  var end = begin + $scope.numPerPage;

  $scope.filteredIdeas = $scope.ideasData.slice(begin, end);

});


// Data
$scope.ideasData = [];

for (var i = 0; i < 100; i++) {
  $scope.ideasData.push('To do ' + i);
}

$scope.filteredIdeas = [];
$scope.currentPage = 1;
$scope.numPerPage = 10;
$scope.totalIdeas = $scope.ideasData.length;
Run Code Online (Sandbox Code Playgroud)

分页设置正确,但这是我在尝试点击下一页(或任何页面)时收到的错误: …

angularjs angular-ui-bootstrap

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

Angularjs - $ uibModal提供程序错误

我正在尝试将$ uibModal注入到我的项目中,但是当控制器加载时,我收到以下错误:

Error: [$injector:unpr] Unknown provider: $uibModalProvider <- $uibModal <- abilityListController
Run Code Online (Sandbox Code Playgroud)

我正在使用NuGet进行包管理.

Angularjs:1.4.8

Bootstrap:3.3.6

Angular-Ui-Bootstrap:0.14.3

这是相关的代码:

的index.html

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
    <link href="Content/bootstrap.css" rel="stylesheet" />
    <script src="scripts/angular.js"></script>
    <script src="scripts/angular-ui/ui-bootstrap.js"></script>
    <script src="app/app.js"></script>
    <script src="app/homeController.js"></script>
    <script src="app/abilityList/abilityListController.js"></script>
</head>
<body>
    <div ng-app="tecApp">
        <div ng-controller="homeController as vm">
            </div>
            <div ng-controller="abilityListController as vm" ng-if="true">
                <div ng-include="'app/abilityList/abilityList.html'"></div>
            </div>
        </div>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

app.js:

angular.module("tecApp", []);
Run Code Online (Sandbox Code Playgroud)

AbilityListController.js:

angular
    .module('tecApp')
    .controller('abilityListController', AbilityListController);

AbilityListController.$inject = ['$uibModal'];

function AbilityListController($uibModal) {
    var vm = {};
    return vm; …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angular-ui-bootstrap

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