我试图在表单上使用angularjs bootstrap下拉切换,我需要能够将所选项目绑定回我的应用程序中新"组织"的模型.
这是我用来创建所有控件的js模块:
var Controls = angular.module('PulseControls', ['ui.bootstrap']);
var booleanButtonCtrl = function($scope) {
$scope.radioModel = true;
};
var currencyDropDownButtonCtrl = function($scope) {
$scope.currencies = [{
id: 1,
name: 'US Dollar'
}, {
id: 2,
name: 'Euro'
}, {
id: 3,
name: 'Australian Dollar'
}];
};
Run Code Online (Sandbox Code Playgroud)
这是我的CreateNewOrganisation控制器的起始代码
function CreateOrganisationController($scope, $http, $window) {
$scope.newOrganisation = {
isActive: true,
};
Run Code Online (Sandbox Code Playgroud)
最后,这是我的html代码片段,其中包含一个for"Status"和一个for Currency,两者都使用ui-bootstrap ...
<div class="form-group">
<label class="control-label">Status</label><br />
<div ng-controller="booleanButtonCtrl">
<div class="btn-group">
<button type="button"
class="btn btn-primary"
data-ng-model="newOrganisation.isActive"
btn-radio="true">
Active
</button>
<button type="button"
class="btn …Run Code Online (Sandbox Code Playgroud) <select class="form-control" data-ng-options="t.name for t in vm.types"
data-ng-model="vm.object.type"></select>
Run Code Online (Sandbox Code Playgroud)
上面的代码显然以标准的表单控制方式显示基本下拉列表.我一直试图弄清楚如何使用Angular的ui-bootstrap指令将其转换为按钮样式下拉列表,但似乎无法获得任何结果.有没人试过这个?
我有一个使用Angular UI-Router的Angular JS项目很好但是我试图实现UI Bootstrap分页指令并且无法计算出正确的策略.
我有一个数据表,一次显示1页,我有分页指令,显示正确的页面链接数.单击链接时,它会获取新的页码,并对api进行Restangular调用以获取新记录并将它们绑定到表中.
这一切都运行良好,但显然当您浏览数据时,URL不会更改,因此用户无法使用浏览器后退/前进按钮来浏览其历史记录.理想情况下,我想使用以下URL:
/contacts
/contacts/page-2
/contacts/page-3
Run Code Online (Sandbox Code Playgroud)
我还想在URL中包含排序,但这是另一个问题.
我可以实现这一点,但是当点击其中一个分页按钮时,手动转换到一个新状态,但这会重新加载控制器及其所有内容,对服务器进行额外的ajax调用,并将丑陋的非样式内容闪烁为它重新创建了分页控制等.
理想情况下,我可以更改URL并添加历史状态,但不会触发实际状态更改并重新加载/运行该视图的控制器.我不确定这是否可行,更不用说怎么做了.
有人有任何想法吗?
javascript angularjs angular-ui angular-ui-bootstrap angular-ui-router
嗨我在运行karma测试运行时在webstorm中收到以下错误
Error: [$injector:nomod] Module 'ui.bootstrap', 'ui.unique' is not available!
You either misspelled the module name or forgot to load it.
If registering a module ensure that you specify the dependencies as the second argument.
Run Code Online (Sandbox Code Playgroud)
我看着互联网,他们说检查依赖文件ui.bootstrap可能会错过这样.
但应用程序工作正常
而只在测试时显示此错误
在我的karma.conf.js中
files: [
//angular files
'app/js/vendor/angular/ui.bootstrap.js',
'app/js/vendor/angular/ui.bootstrap-0.10.0.js',
'app/js/vendor/angular/angular.js',
'app/js/vendor/angular/angular-mocks-0.10.6.js',
'app/js/app.js',
'test/**/*Spec.js'
],
Run Code Online (Sandbox Code Playgroud)
在我的模块声明中
var myApp = angular.module('myApp', ['ui.bootstrap']);
Run Code Online (Sandbox Code Playgroud)
能否请你帮忙 ??
我正在尝试编写一个单元测试,断言正确的变量被发送到Angular-UI Bootstrap组件的resolve属性ui.bootstrap.modal.这是我到目前为止:
// Controller
angular.module('app')
.controller('WorkflowListCtrl', function ($scope, $modal) {
// Setup the edit callback to open a modal
$scope.edit = function(name) {
var modalInstance = $modal.open({
templateUrl: 'partials/editWorkflowModal.html',
controller: 'WorkflowEditCtrl',
scope: $scope,
resolve: {
name: function() { return name; }
}
});
};
});
Run Code Online (Sandbox Code Playgroud)
值得注意的是,该resolve.name属性必须是Angular-UI组件正常工作的功能 - 以前我曾尝试resolve: { name: name }但这不起作用.
// Unit Test
describe('Controller: WorkflowListCtrl', function () {
// load the controller's module
beforeEach(module('app'));
var workflowListCtrl,
scope,
modal;
// Initialize …Run Code Online (Sandbox Code Playgroud) javascript unit-testing jasmine angularjs angular-ui-bootstrap
在angular-ui-bootstrap 演示/文档页面上,手风琴和折叠指令在单击项目时都是动画的.
但是,动画不适用于该页面上的plunker演示.是否缺少某些依赖性或是否可能存在错误?
(在chrome/firefox中测试过)
更新:
我在2015-10-29 更新到版本0.14.3,现在一切都很好.感谢angularUI团队的辛勤工作!
javascript css twitter-bootstrap angularjs angular-ui-bootstrap
PR#4514是否进入了0.14.0标签?我最近重新建立了一个项目,现在0.14.0并没有与0.13.x向后兼容.
DropdownController is now deprecated. Use UibDropdownController instead.
vendor.min.js:15dropdown-toggle is now deprecated. Use uib-dropdown-toggle instead.
vendor.min.js:15dropdown-menu is now deprecated. Use uib-dropdown-menu instead.
vendor.min.js:15dropdown is now deprecated. Use uib-dropdown instead.
Run Code Online (Sandbox Code Playgroud) 我想仅在文本被截断时显示角度UI bootsrap工具提示.我用自定义指令尝试了下面的代码
<div tooltip="{{value}}" tooltip-append-to-body="true" enable-truncate-tooltip>{{value}}</div>
.directive("enableTruncateTooltip", function () {
return {
restrict: 'A',
link: function (scope, elem, attr) {
elem.bind('mouseenter', function () {
var $this = angular.element(this);
if (this.offsetWidth >= this.scrollWidth) {
angular.element('.tooltip').attr('hide-tooltip', true);
}
});
}
}
})
Run Code Online (Sandbox Code Playgroud)
它在angular-ui-bootstrap版本0.12.1中工作正常.但是后来的版本不支持这个.
如何在最新版本的angular-ui-bootstrap中实现相同的功能?
在此先感谢您的帮助.
当面板打开时,我需要将其滚动回刚刚单击的面板的".panel-title".我知道我可以创建一个指令来执行此操作,例如(从此站点获取此信息):
.directive( 'scrollTop', scrollTop );
function scrollTop() {
return {
restrict: 'A',
link: link
};
}
function link( $scope, element ) {
$scope.collapsing = false;
$scope.$watch( function() {
return $(element).find( '.panel-collapse' ).hasClass( 'collapsing' );
}, function( status ) {
if ( $scope.collapsing && !status ) {
if ( $(element).hasClass( 'panel-open' ) ) {
$( 'html,body' ).animate({
scrollTop: $(element).offset().top - 20
}, 500 );
}
}
$scope.collapsing = status;
} );
}
Run Code Online (Sandbox Code Playgroud)
在我应该使用的HTML中:
<div uib-accordion-group is-open="status.openPanel" scroll-top></div> …Run Code Online (Sandbox Code Playgroud) javascript jquery twitter-bootstrap angularjs angular-ui-bootstrap
我尝试过以下问题中提出的解决方案无济于事:
无论如何,要在快速点击时阻止Chrome中的元素蓝色突出显示?
在HTML中,我有以下内容:
<uib-accordion-heading>
<div id="fart1" ng-if="!contactsAccordionIsOpen" class="noSelect" style="outline: none;">Contacts<span class="glyphicon glyphicon-plus-sign pull-right"></span></div>
<div id="fart2" ng-if="contactsAccordionIsOpen" class="noSelect" style="outline: none;">Contacts<span class="glyphicon glyphicon-minus-sign pull-right"></span></div>
</uib-accordion-heading>
Run Code Online (Sandbox Code Playgroud)
整个手风琴标题周围没有出现蓝色轮廓,但形状适合文本.我尝试过内联样式,按ID和类选择,但即使!important它没有改变.
在CSS我有:
#fart1:focus {
border: none !important;
outline: none !important;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
#fart2:focus {
border: none !important;
outline: none !important;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.noSelect {
border: none …Run Code Online (Sandbox Code Playgroud) angularjs ×8
javascript ×4
css ×2
angular-ui ×1
data-binding ×1
hottowel ×1
html5 ×1
jasmine ×1
jquery ×1
karma-runner ×1
tooltip ×1
unit-testing ×1