小编avn*_*avn的帖子

Angularjs - 如何检查唯一输入以及是否存在重复标记均为无效

我有一种情况,用户需要输入由ng-repeat创建的文本区域.如果用户输入已输入的值,则新值和现值都应验证为false.如果其中一个值(现有值或新值)发生更改,则应相应更新验证.

我已经尝试了很多种选择,目前这是接近的,但仍然不是100%.

HTML:

<body ng-app="ap" ng-controller="con">
<table>
    <tr>
        <td>name</td>
    </tr>
    <tr ng-repeat="person in persons">
        <td>
            <ng-form name="personForm">
            <div ng-class="{ 'has-error' : 
                personForm.personName.$invalid }">
                <input type='text'
                name="personName"
                ng-class="empty"
                ng-model="person.name"
                ng-change="verifyDuplicate(this, person)"/>
                </div>
             </ng-form> 
        </td>
    </tr>
</table> 
Run Code Online (Sandbox Code Playgroud)

JavaScript的:

var app = angular.module("ap",[]);

    app.controller("con",function($scope){

    $scope.persons = [
        {name: 'a'},
        {name: 'b'},
        {name: 'c'}
    ];

    $scope.empty = "normal";

    $scope.verifyDuplicate = function(domScope, object){
        for(var i = 0; i < $scope.persons.length; i++) {
            if($scope.persons[i].name === object.name && $scope.persons[i] !== object) {
                domScope.personForm.personName.$setValidity('duplicate',false);
            }
            else {
                domScope.personForm.personName.$setValidity('duplicate',true); …
Run Code Online (Sandbox Code Playgroud)

validation angularjs

14
推荐指数
1
解决办法
3万
查看次数

Using the enter key as tab using only angularjs and jqlite

I have looked at multiple threads and tried a vast variety of solutions. Quite frankly I think I am losing my mind.

I have an ng-repeat with inputs. All that needs to happen is that when the user presses enter, it should shift focus to the next input, basically simulating the tab key functionality.

The code (incomplete): HTML:

<body ng-app="ap" ng-controller="con"> 
<table>
    <tr>
        <th>Name</th>
        <th>Age</th>
    </tr>
    <tr ng-repeat='person in persons'>
        <td>
            <input type='text'
                name="personName"
                ng-model="person.name" 
            />
        </td>
        <td>
            <input type='number' …
Run Code Online (Sandbox Code Playgroud)

angularjs jqlite

6
推荐指数
1
解决办法
7010
查看次数

@ media Screen CSS无效

我已经在我的wordpress主题中的style.css文件中添加了以下代码,但它不起作用.我希望在768和1024px之间的屏幕宽度更改正文背景

CSS:

@media screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
{ 
    body {
        background: #fff;
        border-top: 2px solid #DDDDDD;
    }
}
Run Code Online (Sandbox Code Playgroud)

html css wordpress

1
推荐指数
2
解决办法
3万
查看次数

标签 统计

angularjs ×2

css ×1

html ×1

jqlite ×1

validation ×1

wordpress ×1