这个例子来自angularjs的文档
<form name="myForm" ng-controller="Ctrl">
userType: <input name="input" ng-model="userType" required>
<span class="error" ng-show="myForm.input.$error.required">Required!</span>
</form>
Run Code Online (Sandbox Code Playgroud)
我想用Bootstrap工具提示实现相同的行为.我查看了Angular UI-Bootstraped项目(http://angular-ui.github.io/bootstrap/),但无法弄清楚如何做到这一点.
就像是:
<input type="text" value="Click me!"
tooltip="See? Now click away..."
tooltip-trigger="focus"
tooltip-placement="right"
tooltip-enabled="myForm.input.$error.required" <--- pseudo code
/>
Run Code Online (Sandbox Code Playgroud) 我一直在寻找一些解决方案,用于在ng-grid上显示工具提示,但没有运气.当我在ng-grid上使用cellTemplate来自定义单元格以包含工具提示时,我遇到了各种各样的问题 - 工具提示要么没有显示出来,要么表现得很奇怪,如图所示:http://plnkr.co/edit/MFhwgOvSUFKcyJPse5wf .
我错过了什么吗?有没有人有一个在ng-grid中很好地显示工具提示的解决方案?
最好的祝福.
我正在使用AngularUI datepicker.
我有两个相互影响的日期选择器.一个是例如"开始日期"而另一个是"结束日期".我想要消除无效日期的选项(即结束日期早于开始日期,反之亦然),而不是为两个日期选择器创建验证.
有没有办法在选择日期时重新触发日期禁用属性?(重新触发OTHER日期选择器的日期禁用)
我的傻瓜:我有一个开始和结束日期,你可以看到当你打开每个日期选择器时,你不能选择高于结束日期的开始日期,反之亦然.但是,如果我将开始日期更改为11/21,我希望更新结束日期的日期选择器,以便11/20不再可单击.有没有办法做到这一点?
我遇到了来自Angular-ui-bootstrap的模态服务的问题.我根据以下示例设置了模式:http://angular-ui.github.io/bootstrap/但如果我从模态内容中删除列表项并替换它们,我无法从模态返回结果具有文本区域和不同的ng模型.我会设置一个jsfiddle,但我不知道如何包含显示我想要的特定库(如angular-ui-bootstrap).我有我的模态的截图:http://d.pr/i/wT7G.
以下是我的主控制器,主视图,模态控制器和模态视图中的代码:
主视图代码
<button type="button" class="btn btn-success" ng-click="importSchedule()">import schedule (JSON)</button>
Run Code Online (Sandbox Code Playgroud)
主控制器
$scope.importSchedule = function() {
var modalInstance = $modal.open({
templateUrl: 'views/importmodal.html',
controller: 'ModalInstanceCtrl'
});
modalInstance.result.then(function (result) {
console.log('result: ' + result);
// $scope.schedule = angular.fromJson(scheduleJSON);
}, function () {
console.info('Modal dismissed at: ' + new Date());
});
};
Run Code Online (Sandbox Code Playgroud)
模态视图
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Import schedule(JSON)</h4>
</div>
<div class="modal-body">
<textarea class="form-control" rows="15" ng-model="schedule"></textarea>
<pre>form = {{schedule | json}}</pre>
</div> …Run Code Online (Sandbox Code Playgroud) modal-dialog twitter-bootstrap angularjs angular-ui-bootstrap
我正在使用AngularJS + Twitter Bootstrap和Bootstrap-UI创建一个Web应用程序.当我在按钮上放置工具提示时,它会按预期显示; 但是如果按钮在被单击后被禁用(由底层控制器),并且正在显示工具提示,则工具提示不会被隐藏并永远保留在那里.这是一个复制品:
Plunker:http://embed.plnkr.co/numlaAuLOxh3a03Z7O85/preview
只需将鼠标悬停在按钮上即可显示工具提示,然后单击它.该按钮被禁用,工具提示停留在那里.如何避免此行为并正确隐藏我的提示?
我有一个品牌列表:
<script type="text/ng-template" id="list.brands">
<table class="table table-striped table-bordered bootstrap-datatable datatable dataTable" id="DataTables_Table_0" aria-describedby="DataTables_Table_0_info" ng-controller="BrandsCtrl">
<input type="text" ng-model="searchBox">
<thead>
<tr>
<th><tags:label text="brandid"/></th>
<th><tags:label text="name"/></th>
<th><tags:label text="isactive"/></th>
<th></th>
</tr>
</thead>
<tbody>
<tr id="actionresult{{$index + 1}}" ng-repeat="brand in brands | filter:searchBox">
<td>{{brand.brandid}}</td>
<td>{{brand.name}}</td>
<td>{{brand.isactive}}</td>
<td>
<a class="btn btn-ext-darkblue btn-ext-darkblue savestockbtn" ng-click="open(brand.brandid)"><tags:label text="edit"/></a>
<a class="btn btn-ext-darkblue btn-modal-trigger btn-ext-darkblue savestockbtn" href="/admin.brands/deleteConfirm?brandid={{brand.brandid}}" data-toggle="modal" ><tags:label text="delete"/></a>
</td>
</tr>
</tbody>
</table>
</script>
Run Code Online (Sandbox Code Playgroud)
此列表有2个按钮的品牌线; 编辑和删除."编辑"按钮可打开品牌编辑表格的模式:
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib tagdir="/WEB-INF/tags" prefix="tags"%>
<%@taglib uri="/WEB-INF/tlds/fields.tld" prefix="fields"%>
<div class="row-fluid sortable"> …Run Code Online (Sandbox Code Playgroud) 问题就是这一切.
我追求高低,并没有看到一种方法,但是,在我破解模板之前,我以为我会问这里.
只是为了说清楚 - 我希望能够在日期选择器的顶部添加一些文本(这是一个弹出窗口,如果这有任何区别),例如"你的生日是什么时候?".
我使用角度ui-bootstrap的verion 0.14.2.我无法在弹出窗口中显示行返回.我使用popover-html指令和一个字符串如
Limite inférieure<br>Limite supérieure
Run Code Online (Sandbox Code Playgroud)
它给出以下错误:
Lexer Error: Unexpected next character at columns 41-41 [é] in expression [<div>Approchant des limites<br>Limite supérieure: 34:12<br>Limite inférieure: -34:12</div>].
Run Code Online (Sandbox Code Playgroud)
我尝试在$ sce.trustAsHtml调用中包装我的字符串,但它没有改变一件事.
我正在使用Angular UI Bootstrap Datepicker:https://angular-ui.github.io/bootstrap/#/datepicker
当我使用从服务器接收的数据呈现表单时,datetime字段存在问题.我的输入日期选择器如下所示:
<form name="itemForm">
<input type="datetime" class="form-control" id="startedAt" name="startedAt"
ng-model="item.startedAt"
ng-click="open($event, 'startedAt')"
uib-datepicker-popup="yyyy-MM-dd"
is-open="datepickers.startedAt"
/>
</form>
Run Code Online (Sandbox Code Playgroud)
我的服务器将响应日期时间作为JSON字符串返回:
{
...
startedAt: "2015-05-29T02:00:00+0200"
}
Run Code Online (Sandbox Code Playgroud)
当我将响应数据分配给模型时$scope.item = response;,会正确呈现datepicker输入字段(选择正确的日期并按照我选择的格式正确格式化).问题是验证没有通过.我明白了:
itemForm.startedAt.$invalid == true
Run Code Online (Sandbox Code Playgroud)
我注意到绑定到datepicker字段的数据应该是Date对象而不是字符串(当我从datepicker中选择新日期时,$scope.item.startedAt是一个Date)
我设法解决了这个问题并在控制器中执行此操作:
$scope.item = response;
$scope.item.startedAt = new Date($scope.item.startedAt);
Run Code Online (Sandbox Code Playgroud)
它以这种方式工作......但我不希望每次从服务器获得响应时手动转换字符串do日期.我试图创建一个指令,我可以将其分配给datepicker输入字段,以便它ng-model为我转换:
.directive("asDate", function () {
return {
require: 'ngModel',
link: function (scope, element, attrs, modelCtrl) {
modelCtrl.$formatters.push(function (input) {
var transformedInput = new Date(input);
if (transformedInput != input) …Run Code Online (Sandbox Code Playgroud) 我读了这方面的各种资源,但仍然无法找到方法.这里的问题是我想将两个不同的项目合并在一起.我的同事正在研究他在AngularJS中设计的一个功能.我使用VueJS开发了我的功能.管理层随后决定将两者合并在一起.在第一个项目启动的用户界面中,将提供一个链接,从我的网页在VueJS中设计的位置开始.
我在VueJS服务器上本地运行我的项目npm start,也使用快速服务器.但是第一个项目只运行node app.js,然后在本地运行.
以下是他的项目描述的截图:
这是我的项目细节:
我的index.html文件包含以下内容:
<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Error Details and Description</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<div id="app"></div>
<script src="bundle.js"></script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
第一个项目中包含的另一个index.html包含我的应用程序将通过其启动的链接的代码.该链接包含此代码,可以重定向到我的代码:
<li><a><i class="fa fa-edit"></i>Administration<span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu">
<li><a href="#!errorinput"><i class="fa fa-database"></i>Manage Error Descriptions</a></li>
Run Code Online (Sandbox Code Playgroud)
相应的errorinput.js文件包含以下代码:
'use strict';
app.config(function ($routeProvider) {
$routeProvider
.when("/errorinput", {
templateUrl: "views/errorinput.html"
});
});
app.controller('ErrorInputCtrl', ['$scope', '$http', function ($scope, $http) {
// Implement me!
}]);
Run Code Online (Sandbox Code Playgroud)
知道如何将它们合并在一起以获得所需的功能吗?
编辑:所以我确实找到了在一台服务器上运行这两个项目的方法.我在我的VueJS项目中包含了AngularJS的所有依赖项.角应用程序运行正常,但现在,VueJS网页没有与angularJS一起出现.当我给出我的VueJS应用程序的相对路径时,它似乎在后台.任何想法我现在如何在这个引导的AngularJS应用程序中路由我的VueJS?这里提到了有关此问题的更多详细信息:
angularjs ×10
angular-ui ×2
datepicker ×2
javascript ×1
json ×1
modal-dialog ×1
ng-grid ×1
node.js ×1
vue.js ×1