下拉菜单在Angular-UI-Bootstrap中不起作用?使用Bootstrap-3 CSS
以下是代码.链接Click me for a dropdown显示出来.但是不要在点击时切换.怎么了?
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script>function DropdownCtrl($scope) {
$scope.items = [
"The first choice!",
"And another choice for you.",
"but wait! A third!"
];
}
</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js"></script><script type="text/javascript" src="js/ui-bootstrap-tpls-0.5.0.min.js"></script><script type="text/javascript" src="js/dropdownToggle.js"></script>
</head>
<body>
<li ng-controller="DropdownCtrl" class="dropdown">
<a href='#' class="dropdown-toggle"> Click me for a dropdown </a>
<ul class="dropdown-menu">
<li ng-repeat="choice in items"><a>{{choice}}</a>
</li>
</ul>
</li>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) twitter-bootstrap angular-ui angular-ui-bootstrap twitter-bootstrap-3
我注意到ui-bootstrap模态范围有些奇怪.似乎在使用ng-model时,你必须引用$ parent来获得模态控制器的范围.在我plunker注意,其它属性这样的NG选项不需要$父: http://plnkr.co/edit/xGSHz4EkZvGr2D6CUeBz?p=preview
知道为什么吗?我在这里发现了一个类似的问题: Angular UI模式的范围问题
这导致我尝试$ parent更改,但我无法评论该线程,因为我没有足够的声誉.
知道为什么范围似乎改变了吗?
谢谢!
我已经实现了模态指令,并将$modal.open选项背景设置为false.但是,现在我可以触发多个模态打开.有一种方法可以防止触发按钮在一个模态打开后触发吗?
var accountSummaryCtrl = function ($scope, $modal, $log) {
$scope.open = function () {
var modalInstance = $modal.open({
templateUrl: '/Apps/generic/modal/Templates/AccountSummary.html',
controller: ModalInstanceCtrl,
backdrop: false
});
modalInstance.result.then(function (selectedItem) {
$scope.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
};
};
Run Code Online (Sandbox Code Playgroud)
谢谢
我有一个带有状态通知的工具提示(http://angular-ui.github.io/bootstrap/),但是当这个通知很大时,它会溢出屏幕限制.这里是正在发生的事情的印刷品:
我找不到角度ui中处理这个问题的任何属性.
提前致谢!
javascript twitter-bootstrap angularjs angular-ui-bootstrap twitter-bootstrap-tooltip
有没有办法获取手风琴组是否开放?我知道有isOpen指令,但我不确定是否有办法在html中访问该状态.使用(和滥用?)双向绑定我可以设置一个变量来保持该状态,但是如果不执行像isOpen0,isOpen1,isOpen2等那样的嵌套手风琴它将无法解决.我也可以使用ng-init来"声明"一个新的isOpen在嵌套手风琴的范围,但这听起来不是一个好主意.
<accordion>
<accordion-group is-open="isOpen">
<accordion-heading>
<div ng-class="{'myClass': isOpen}">Static Text</div>
</accordion-heading>
This content is straight in the template.
</accordion-group>
</accordion>
Run Code Online (Sandbox Code Playgroud)
我有以下弹出窗口并尝试添加关闭按钮以便能够关闭它.
.directive("popoverHtmlUnsafePopup", function () {
'use strict';
return {
restrict: "EA",
replace: true,
scope: { title: "@", content: "@", placement: "@", animation: "&", isOpen: "&", manualHide: '&' },
templateUrl: "views/popover/popover-html-unsafe-popup.html"
};
})
.directive("popoverHtmlUnsafe", [ '$compile', '$timeout', '$parse', '$window',"$tooltip", function ($compile, $timeout, $parse, $window, $tooltip) {
'use strict';
return $tooltip("popoverHtmlUnsafe", "popover", "click");
}]);
<div class="popover {{placement}}" ng-class="{ in: isOpen(), fade: animation() }">
<div class="arrow"></div>
<div class="popover-inner">
<h3 class="popover-title" ng-bind="title" ng-show="title"></h3>
<div class="popover-content" bind-html-unsafe="content">
</div>
<button type="button" class="close" popover-trigger="close">×</button>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
只是不确定要调用的事件或函数 …
使用ui-bootstrap我可以使用自定义模板进行弹出.但是我面临几个问题:
1 - 关闭按钮
我可以popover-is-open用来打开和关闭.不过,我则需要跟踪的变量,如果我有20个popovers(大表格)页,然后它不是一个很好的解决方案,以在控制这么多的变数只是为了显示和隐藏在单击关闭里面的一个酥料饼模板.
2 - popover中的内容/数据
我可以从模板中的控制器访问模板内容的数据,但是我需要为20个弹出窗口编写20个模板.
例如
$scope.popovers = {
un: {visible: false, title: 'Help', content: 'some explanation here'},
ts: {visible: false, title: 'another title', content: 'some explanation here again'}
}
Run Code Online (Sandbox Code Playgroud)
然后是模板:
<script type="text/ng-template" id="myPopoverTemplate.html">
<div>
<a class="pull-right clickable" ng-click="popovers.un.visible = false"><i class="fa fa-close"></i></a>
<div class="tooltip-info__arrow"></div>
<strong>{{popovers.un.title}}</strong>
<p>{{popovers.un.content}}</p>
</div>
</script>
Run Code Online (Sandbox Code Playgroud)
然后再次:
<script type="text/ng-template" id="myPopoverTemplate.html">
<div>
<a class="pull-right clickable" ng-click="popovers.ts.visible = false"><i class="fa fa-close"></i></a>
<div class="tooltip-info__arrow"></div>
<strong>{{popovers.ts.title}}</strong>
<p>{{popovers.ts.content}}</p>
</div>
</script>
Run Code Online (Sandbox Code Playgroud)
更新: 我试图覆盖使用装饰,但不能.是否有任何内置选项来减少这种"重复性"或,,,如何覆盖自定义行为?
我有以下使用情况的问题提前键入:
因此,故事的道德是在第一种情况下,如果未从列表中选择字符串并且它是列表字符串的子字符串,则应该清除字符串...
那么,也许是一个类型搜索焦点设置?
<input type="text" focus-me="opened" ng-focus="onFocus($event)" ng-show="opened" ng-trim="false" ng-model="selected" empty-typeahead typeahead="state for state in states | filter:$viewValue:stateComparator" class="form-control" />
Run Code Online (Sandbox Code Playgroud)
(function () {
var secretEmptyKey = '[$empty$]'
angular.module('plunker', ['ui.bootstrap'])
.directive('focusMe', function($timeout, $parse) {
return {
//scope: true, // optionally create a child scope
link: function(scope, element, attrs) {
var model = $parse(attrs.focusMe);
scope.$watch(model, function(value) {
if(value === true) {
$timeout(function() {
element[0].focus();
});
}
});
}
};
})
.directive('emptyTypeahead', function …Run Code Online (Sandbox Code Playgroud) typeahead angularjs angular-ui-bootstrap angular-ui-typeahead
我觉得我已经尝试了一切,我仍然得到错误:
无法加载模板:uib/template/modal/window.html
在我的索引文件中,我添加了以下内容:
<script src="node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js"></script>
<script src="node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js"></script>
Run Code Online (Sandbox Code Playgroud)
在我的app文件中添加:
'ui.bootstrap',
Run Code Online (Sandbox Code Playgroud)
在我的控制器文件中,我添加了以下内容:
$uibModal
Run Code Online (Sandbox Code Playgroud)
和
this.openPayment = function () {
var modalInstance = $uibModal.open({
ariaLabelledBy: 'modal-title',
ariaDescribedBy: 'modal-body',
templateUrl: 'payment.html',
controller: 'paymentController',
controllerAs: '$ctrl',
size: 'lg',
});
}
Run Code Online (Sandbox Code Playgroud)
在我的paymentControlleri中添加了以下内容:
angular.module('Payment').controller('paymentController', function ($uibModalInstance) {
var ctrl = this;
});
Run Code Online (Sandbox Code Playgroud)
而且payment.html:
<div class="modal-header">
<h3 class="modal-title" translate="ACADEMY.EDIT.COURSES.CREATE"></h3>
</div>
<div class="modal-body">
</div>
<div class="lb-modal-footer">
<a class="btn btn-grey" tooltip="{{ 'TOOLTIP.CANCEL' | translate }}" ng-click="CTRL.cancel()"><i
class="fa fa-ban"></i></a>
<button class="btn btn-success m-l-xs {{CTRL.academyCourse.course ? '':'disabled'}}" tooltip="{{ …Run Code Online (Sandbox Code Playgroud) 我想通过单击输入字段打开 bootstrap 4 日期选择器。我不想显示日历图标 我该如何解决这个问题?