基本上,我正在尝试更改/自定义ui.bootstrap.accordion的行为.一切正常,除了与ui-router的集成.
这是我想要使用手风琴的方式:
<accordion> <!-- this element is actually separate view in a parent state of the accordion-group's below.-->
<accordion-group ui-sref="site.home.newsID_1"> <!-- accordion-groups will be generated with ng-repeat.-->
<accordion-heading>
News 1
</accordion-heading>
<p>This is</p>
</accordion-group>
<accordion-group ui-sref="site.home.newsID_2">
<accordion-heading>
News 2
</accordion-heading>
<p>Home News's</p>
</accordion-group>
<accordion-group ui-sref="site.home.news.newsID_3">
<accordion-heading>
News 3
</accordion-heading>
<p>Preview and navigation</p>
</accordion-group>
</accordion>
Run Code Online (Sandbox Code Playgroud)
下面是手风琴的修改模板:
<div ng-mouseenter="isOpen = !isOpen" ng-mouseleave="isOpen = !isOpen">
<div class="accordion-group" ng-class="{transparentBackground: isClicked}">
<div class="accordion-heading">
<a id="link" ui-sref="site" class="accordion-toggle" ng-click="isClicked = !isClicked" accordion-transclude="heading">
{{heading}}
</a>
</div>
<div …Run Code Online (Sandbox Code Playgroud) javascript angularjs angularjs-directive angular-ui-bootstrap angular-ui-router
出现切换按钮但不起作用.我现在在网上也有相同的代码,它不起作用,但在Plunker它正在工作.
代码是:
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="nalogo-wrapper">
<img class="img-responsive" src="http://placehold.it/50x50&text=Logo" />
</div>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="#/view1"><span class="glyphicon glyphicon-home"></span> Etusivu</a></li>
<li><a href="#/view2">Palvelut</a></li>
<li><a href="#/view3">Yhteistiedot</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<div id="main">
<div ng-view>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
感谢帮助!萨米
togglebutton navbar twitter-bootstrap angularjs angular-ui-bootstrap
我正在使用角度引导类型.我想进行一项增强,如果项目不在列表中,则用户可以添加新项目(可能正在键入的项目显示在列表底部,带有加号按钮或类似内容) .
是否有一种简单的方法来进行此增强?如果没有,还有其他什么可以做到这一点?
我正在使用Angular和UI Bootstrap Datepicker(https://angular-ui.github.io/bootstrap/),我正在尝试更新日期类,以显示使用现有customClass在特定日期发生的事情.当传递的日期是同步但使用$ resource不是异步时,这可以正常工作.
HTML
<uib-datepicker custom-class="getDayClass(date, mode)" ng-model="dt" min-date="minDate" show-weeks="false" starting-day="1" class="well well-sm" ng-change="selectDateChange()"></uib-datepicker>
Run Code Online (Sandbox Code Playgroud)
JS
$scope.getDayClass = function (date, mode) {
if ($scope.myCalendarEvents.length > 0) {
if (mode === 'day') {
var dayToCheck = new Date(date).setHours(0, 0, 0, 0);
for (var i = 0; i < $scope.myCalendarEvents.length; i++) {
var currentDay = new Date($scope.myCalendarEvents[i].startDate).setHours(0, 0, 0, 0);
if (dayToCheck === currentDay) {
return "full";
}
}
}
return '';
}
};
Run Code Online (Sandbox Code Playgroud)
查看异步调用的示例(ps.这不是我的Plnkr):
我的目标是创建一个也有输入掩码的UI Bootstrap datepicker.
该datepicker指令仅验证使用弹出窗口选择的日期,而不是用户手动输入的日期,因此我查找了如何为文本输入添加自定义验证.
我在Plunk中完成了所有这些工作.
以下是重点:
<!-- HTML -->
<span>Errors: {{myForm.myDate.$error}}</span>
<input
name="myDate"
type="text"
class="form-control"
ng-class="{error: myForm.myDate.$invalid && myForm.myDate.$dirty}"
datepicker-popup="MM/dd/yyyy"
ng-model="dt"
is-open="opened"
min-date="'09/01/2015'"
max-date="'11/11/2015'"
ng-required="true"
show-weeks="false"
show-button-bar="false" />
// JavaScript
.controller('DatepickerDemoCtrl', function ($scope) {
$scope.dt = undefined;
$scope.open = function($event) {
$scope.opened = !$scope.opened;
};
$scope.today = new Date();
})
.config(function($provide) {
$provide.decorator('datepickerPopupDirective', function($delegate) {
var directive = $delegate[0];
var link = directive.link;
directive.compile = function() {
return function(scope, iEl, …Run Code Online (Sandbox Code Playgroud) javascript validation twitter-bootstrap angularjs angular-ui-bootstrap
我在我的角度项目中包含了bootstrap ui模块,现在我想扩展例如'ui-bootstrap-tpls.js'中的datepicker控制器'UibDatepickerController'以及更多功能.
好的,我可以编辑ui bootstrap文件,但这不是我想要的.
我想一个模块化的文件(也许一个自己的指令),因此不存在大的问题,当一个用户界面引导更新传入.
那可能吗?什么是最佳做法?
我正在尝试在UI引导程序中的typeahead中实现显示更多结果功能.最初它应该加载5个结果,然后如果结果超过5我想显示一个显示更多结果选项以再次从API加载所有结果(没有限制).
这是我在模板中的预先定义:
<input type="text" name="FullName" id="FullName"
class="form-control" autocomplete="false" required="required"
placeholder="Search by name"
uib-typeahead="ent as ent.FullName for ent in vm.findEntities($viewValue)"
typeahead-popup-template-url="entityPopup.tpl.html"
typeahead-template-url="popupMatch.tpl.html"
typeahead-on-select="vm.entitySelected($item)"
ng-model="vm.FullName">
Run Code Online (Sandbox Code Playgroud)
我在父 - 父控制器中有一个变量,其中包含结果的计数.$parent.$parent.vm._entityTotalResults.如果该计数超过5,那么我想显示一个" 显示更多"按钮,该按钮可以加载更多结果并将其填充到预先输入结果中.
我entityPopup.tpl.html的内容如下:
只是添加了一个的默认值 <li></li>
<ul class="dropdown-menu" ng-show="isOpen() && !moveInProgress" ng-style="{top: position().top+'px', left: position().left+'px'}" style="display: block;" role="listbox" aria-hidden="{{!isOpen()}}">
<li ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index)" role="option" id="{{::match.id}}">
<div uib-typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
</li>
<li ng-show="$parent.$parent.vm._entityTotalResults > 5">SHOW MORE</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
我的先行功能 …
angularjs bootstrap-typeahead angular-ui-bootstrap angular-ui-typeahead
我想在焦点上调整textArea中的行数,在模糊时删除它们.除了焦点,我想显示一个隐藏的div层.我目前的解决方案是
<textarea class="form-control" rows="1" placeholder="Please enter text..."
onfocus="this.rows=3" ng-focus="isVisible = !isVisible" onblur="this.rows=1"
ng-blur="isVisible = !isVisible"></textarea>
Run Code Online (Sandbox Code Playgroud)
从上面可以看出,我必须使用两个属性,即HTML onfocus增加行和ng-focus更新isVisible(显示和隐藏div).它有效,但我想知道是否可以使用ng-focus和ng-blur增加和减少行数.
Div层我正在展示和隐藏
<div class="row" ng-show="isVisible" />
Run Code Online (Sandbox Code Playgroud)
提前致谢
我有这两种观点:
1)foo.html
<p>Hello {{name}}</p>
Run Code Online (Sandbox Code Playgroud)
2)foo-as-modal.html
<div class="modal-header">
<h3 class="modal-title">I'm a modal</h3>
</div>
<div class="modal-body">
<ng-include src="'foo.html'"></ng-include>
</div>
<div class="modal-footer">
<button class="btn btn-default" ng-click="cancel()">Close</button>
</div>
Run Code Online (Sandbox Code Playgroud)
foo.html的控制器是fooController:
angular.module('myApp').controller('fooController', ['$scope','$uibModalInstance', function($scope,$uibModalInstance) {
$scope.name = "John"
$scope.cancel = function () {
$uibModalInstance.dismiss('cancel');
};
}]);
Run Code Online (Sandbox Code Playgroud)
我需要注入$uibModalInstance到fooController该.dismiss工作
当我foo-as-modal.html作为模态调用时,这很有效,即:
var modalInstance = $uibModal.open({
templateUrl: 'foo-as-modal.html',
controller: 'fooController',
scope: $scope.$new(),
size: 'lg'
});
Run Code Online (Sandbox Code Playgroud)
但是当我foo.html作为普通视图(via $routeProvider和ng-viewdirective)调用时,它会抛出错误,即:
.when('/foo', {
templateUrl: 'foo.html',
controller: 'fooController'
})
Run Code Online (Sandbox Code Playgroud)
错误是: …
这是我的第一个问题......我必须这样做:
但我搜索了很多,没有什么对我有用,我在我的HTML和CSS中有类似的东西
.thumbnail {
position: relative;
margin-bottom: 0;
border: 0;
border-color: transparent;
}
.caption {
position: absolute;
top: 40%;
left: 0;
width: 100%;
}Run Code Online (Sandbox Code Playgroud)
<div id="box-search">
<div class="thumbnail text-center">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/7/7d/Granola03242006.JPG/280px-Granola03242006.JPG" alt="">
<div class="caption">
<p>contacto@windberg.cl</p>
<p>+56983874071 | +56228231294</p>
<p>El Aguilucho 3174, Providencia, Región Metropolitana</p>
</div>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
这工作,但当我使用铬的响应模式时,文本离开图像
(对不起我的英语,我说西班牙语)