小编Leo*_*eon的帖子

如何使用ng-messages显示Angularjs中的服务器错误

我有我的角度应用程序验证注册表单.提交时,服务器也验证数据.我正在使用ng-messages以角度输出错误消息.

这是我的表单的缩短版本,到目前为止工作得很好.

<form name="signUpForm" novalidate data-ng-submit="attemptSignUp()">
    <label for="firstName">First name</label>
    <input type="email" name="email" id="email" required data-ng-model="data.user.email" />
    <div class="error" data-ng-messages="signUpForm.email.$error" data-ng-show="signUpForm.$submitted" data-ng-cloak>
        <p data-ng-message="required">Please provide your email</p>
    </div>
</form>
Run Code Online (Sandbox Code Playgroud)

服务器验证电子邮件地址是唯一的,如果不是,则返回422错误(来自Laravel 5),错误数组.

[
    'email' => 'This email is already in use'
]
Run Code Online (Sandbox Code Playgroud)

我想合并这个,以及从服务器发回其相关ng-messages块的任何其他消息.知道我怎么能完成它吗?

javascript angularjs

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

如何防止使用hammer.js触摸默认值

如果用触摸设备点击锚点我想阻止锚点点击,但是如果用鼠标点击它可以正常操作.

原因是,在桌面上,您将鼠标悬停在锚点上以查看更多信息,然后单击以查看产品.

在手机上,我希望第一次点击显示信息,第二次查看产品.

我已经尝试过以下各种变体:

$('article.product aside a.link').hammer().on('tap', function(ev) {

    if (ev.gesture.pointerType == 'touch') {
        ev.gesture.srcEvent.preventDefault();

        return false;
    }

});
Run Code Online (Sandbox Code Playgroud)

有没有人对此有任何想法?谢谢!

javascript mobile jquery javascript-events hammer.js

8
推荐指数
1
解决办法
4415
查看次数

UITableViewCell中的UITextField在插入后成为FirstResponder

正如标题所述,我有一个UITextField内部UITableViewCell.

我的tableView列出了一个名为的数组中的项 tallies: [String]

我正在按钮上插入一个新条目,并在新单元格中设置动画.我希望titleTextFieldbecomeFirstResponder一旦rowAnimation已完成,但至今无法得到它的工作.

新的行完美地动画,但titleTextField不会becomeFirstResponder

这是我尝试过的:

CATransaction.begin()
CATransaction.setCompletionBlock {
    let cell = self.tableView(self.tableView, cellForRowAtIndexPath: self.editingIndexPath!) as! TallyCell
    cell.titleTextField.hidden = false
    cell.titleTextField.becomeFirstResponder()
}

tableView.beginUpdates()
tallies.append("Example")
tableView.insertRowsAtIndexPaths([editingIndexPath!], withRowAnimation: .Left)
tableView.endUpdates()

CATransaction.commit()
Run Code Online (Sandbox Code Playgroud)

uitableview uitextfield becomefirstresponder ios swift

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

UIPickerView viewForRow UILabel忽略帧

我正在使用UILabel作为我的UIPickerView的自定义视图,我正在尝试将标签从左侧填充10px左右.但是,无论我将UILabel设置为什么帧,它都会被忽略.

我基本上试图制作一个日期选择器,年份组件中有一个"未知"选项.我是iOS开发人员的新手.将UIDatePicker子类化并添加"未知"选项是否可能/更优雅?

这是我的代码:

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UILabel* tView = (UILabel*)view;

    if (!tView)
    {
        tView = [[UILabel alloc] initWithFrame:** Any CGRect here **];

        tView.backgroundColor = [UIColor redColor];
        tView.font = [UIFont boldSystemFontOfSize:16.0];

        if (component == 0)
        {
            tView.textAlignment = NSTextAlignmentCenter;
        }
    }

    // Set the title
    NSString *rowTitle;

    if (component == 0)
    {
        rowTitle = [NSString stringWithFormat:@"%d", (row + 1)];
    }
    else if (component == 1)
    {
        NSArray *months = [[NSArray alloc] initWithObjects:@"January", @"February", @"March", @"April", …
Run Code Online (Sandbox Code Playgroud)

objective-c uipickerview ios

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