使用TokenInput插件并使用AngularJS内置的formController验证.
现在我正在尝试检查字段是否包含文本,然后将字段设置为有效(如果有).使用插件的问题是它创建了自己的输入,然后是一个用于stlying的ul + li.
我可以访问控制器中的addItem(formname)和我的功能,我只需将其设置为$ valid即可.
标记.
<form class="form-horizontal add-inventory-item" name="addItem">
<input id="capabilities" name="capabilities" token-input data-ng-model="inventoryCapabilitiesAutoComplete" data-on-add="addCapability()" data-on-delete="removeCapability()" required>
<div class="required" data-ng-show="addItem.capabilities.$error.required" title="Please enter capability."></div>
</form>
Run Code Online (Sandbox Code Playgroud)
JS.
$scope.capabilityValidation = function (capability) {
if (capability.name !== "") {
addItem.capabilities.$valid = true;
addItem.capabilities.$error.required = false;
} else {
addItem.capabilities.$valid = false;
addItem.capabilities.$error.required = true;
}
};
Run Code Online (Sandbox Code Playgroud)
当TokenInput输入并传入对象时,我正在运行capabilityValidation函数.
编辑:
在我的输入上找到ng-model做了东西并获得自动完成结果,这就是为什么我不能使用ng-valid来工作,因为它基于模型.
$scope.inventoryCapabilitiesAutoComplete = {
options: {
tokenLimit: null
},
source: urlHelper.getAutoComplete('capability')
};
Run Code Online (Sandbox Code Playgroud)
我没有编写这个自动完成实现,是否有另一种方法可以访问ng-model attr并将模型函数移动到其他地方?
我有一个模型在storeLocations对象中返回一个isDefault值.如果isDefault返回true,我不想将组中的单选按钮设置为已选中.
不确定我是否需要执行$ each(数据,函数(索引,值)并迭代返回的每个对象,或者是否有更简单的方法使用角度构造执行此操作.
宾语:
storeLocations = [
{
... more values,
isDefault: true
}
]
Run Code Online (Sandbox Code Playgroud)
标记:
<tr ng-repeat="location in merchant.storeLocations">
<td>{{location.name}}</td>
<td>{{location.address.address1}}</td>
<td>{{location.address.address2}}</td>
<td>{{location.address.city}}</td>
<td>{{location.address.stateProvince}}</td>
<td>{{location.address.postalCode}}</td>
<td>{{location.address.country}}</td>
<td>{{location.website}}</td>
<td>{{location.zone}}</td>
<td><input type="radio" ng-model="location.isDefault" value="{{location.isDefault}}" name="isDefault_group"></td>
Run Code Online (Sandbox Code Playgroud) 根据输入模型提供一种价格范围/评级功能.在加载时,当它从后端设置时,它以整数开始,但是当你输入它时,它会变成一个字符串.在Angular中有什么方法可以将输入的值声明为整数吗?
HTML:
<input type="text" name="sellPrice" id="sellPrice" class="sell-price" data-ng-model="menu.totalPrice" data-ng-change="updateMenuPriceRange()"required>
Run Code Online (Sandbox Code Playgroud)
JS:
$scope.updateAggregatePricing();
if ($scope.menu.totalPrice === 0) {
$scope.menuPriceRange = "";
} else if ($scope.menu.totalPrice < 10) {
$scope.menuPriceRange = "$";
} else if ($scope.menu.totalPrice >= 10 && $scope.menu.totalPrice <= 12.50) {
$scope.menuPriceRange = "$$";
} else if ($scope.menu.totalPrice >= 12.51 && $scope.menu.totalPrice < 15) {
$scope.menuPriceRange = "$$$";
} if ($scope.menu.totalPrice >= 15) {
$scope.menuPriceRange = "$$$$";
} else {
$scope.menuPriceRange = "";
}
Run Code Online (Sandbox Code Playgroud) 尝试根据我当前的控制器或当前路径(URL Segment 1)设置一个类.
就像是
<body class="{{controllerName}}">
Run Code Online (Sandbox Code Playgroud)
这样,如果我需要针对CSS特异性定位单独的页面,它就会变得容易.
import { GoogleMapsAPIWrapper } from '@agm/core';
import { Component, Input } from '@angular/core';
@Component({
selector: 'core-map',
styleUrls: [ './map.component.scss' ],
templateUrl: './map.component.html',
})
export class MapComponent {
constructor(
public gMaps: GoogleMapsAPIWrapper
) {}
public markerClicked = (markerObj) => {
this.gMaps.setCenter({ lat: markerObj.latitude, lng: markerObj.longitude });
console.log('clicked', markerObj, { lat: markerObj.latitude, lng: markerObj.longitude });
}
}
console output: Object {lat: 42.31277, lng: -91.24892}
Run Code Online (Sandbox Code Playgroud)
也试过panTo同样的结果.
如果某事是真的,只是尝试应用一个类.关于http://docs.angularjs.org/api/ng.directive:ngClass的文档非常简短
试图favorite在liif 上添加一类1 === true
这是我的模拟对象
$scope.restaurantListFromSearch = [
{restaurantName: "Zocala",
details: {
image: "http://placehold.it/124x78",
url: "#",
cuisineType: ["Sandwiches", "American", "BBQ"],
description: "Modern, healthy, awesome BBW",
priceRange: "$",
userFavorite: 0
}},
{restaurantName: "Subway",
details: {
image: "http://placehold.it/124x78",
url: "#",
cuisineType: ["Sandwiches", "American", "BBQ"],
description: "Modern, healthy, awesome BBW",
priceRange: "$",
userFavorite: 1
}},
{restaurantName: "Hungry Howies",
details: {
image: "http://placehold.it/124x78",
url: "#",
cuisineType: ["Sandwiches", "American", "BBQ"],
description: "Modern, healthy, awesome BBW",
priceRange: "$", …Run Code Online (Sandbox Code Playgroud) 我有一排产品div.需要在每四个项目后添加一个明确的div.4连续.
我现在正在使用jQuery('.product:nth-of-type(4n+2)').after("<div class='clear'></div>");,但这不支持IE8.由于我们使用的是jQuery,因此选择性修复程序在这种情况下不起作用.
我也试过了
addDynamicRow = function() {
var divs = $(".product-section > .product");
for(var i = 0; i < divs.length; i+=4) {
divs.slice(i, i+4).wrapAll("<div class='row'></div>");
}
$('.row').after("<div class='clear'></div>")
}
addDynamicRow();
Run Code Online (Sandbox Code Playgroud)
但是,这也抓住了其他产品部分包装中的所有产品div,并将它们分成四个一组,无论它们在哪里.
有人知道一轮工作吗?我找不到解决方案了.
谢谢!
1/15/13更新: jQuery 1.9现在支持所有浏览器中的以下CSS3选择器,一直回到IE6 :: nth-last-child,:nth-of-type,:nth-last-of-type,: first-of-type,:last-of-type,:only-of-type,:target,:root和:lang.
输入类型文件是否有关闭本机 iOS 6 处理的属性?
我想禁用“拍照”功能,但保留“选择图像”。

试图为离子写一些量角器测试,意识到选择器element( by.css('.selector'));不再滚动到元素.当它在浏览器中不可见时,会自动失败测试.
我花了一段时间来搞清楚.使用a ptor.sleep(2000)来延迟页面browser.get('domain');然后如果我滚动查看元素的部分,它们会通过(如预期的那样).
我相信这与离子接管滚动事件有关.
有没有人遇到过这个或者为所有元素都有某种scrollTo实现?
样本测试
"use strict";
/* Tests */
var ptor = protractor.getInstance();
describe( "Register page", function ()
{
browser.get( "#/register" );
ptor.sleep(2000);
it( "Check SMS Preference", function ()
{
var smsLabelConfirm = element( by.css( ".sms-confirm" ) ),
smsLabelDeny = element( by.css( ".sms-deny" ) ),
smsInputConfirm = element ( by.id( "sms-confirm" ) ),
smsInputDeny = element ( by.id( "sms-deny" ) );
smsLabelConfirm.click();
expect( smsInputConfirm.getAttribute( "checked" ) ).toBe( "true" );
expect( smsInputDeny.getAttribute( "checked" …Run Code Online (Sandbox Code Playgroud) angularjs ×5
javascript ×5
angular ×2
typescript ×2
css ×1
file ×1
html ×1
integer ×1
ios ×1
ios6 ×1
jquery ×1
json ×1
protractor ×1
radio-group ×1
routes ×1
validation ×1