小编Ash*_*eer的帖子

Angular 2在单击子项时阻止单击父项

我有一个嵌套一级的点击事件.当我点击孩子时,会调用预期的函数,但也会调用父函数.这是代码

<li class="task-item" *ngFor="let task of tasks" (click)="showTask(task.name)">
    <input type="checkbox" [ngModel]="task.taskStatus" (ngModelChange)="changeTaskStatus($event)" />
</li>
Run Code Online (Sandbox Code Playgroud)

所以当复选框改变changeTaskStatus()并且showTask()一起调用时.我希望父母在复选框更改时保持安静.我该如何实现这一目标?在Angular 1中很容易处理这个问题

我试过的事情都失败了

用于$event.stopPropagation()复选框的单击事件,该事件未发生任何变化

<input type="checkbox" [ngModel]="task.taskStatus" (click)="$event.stopPropagation()" (ngModelChange)="changeTaskStatus($event)" />
Run Code Online (Sandbox Code Playgroud)

angular2-template angular

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

Angular2无法在promise中访问"this"

我无法调用ng2-sweetalert2插件的承诺内的函数

swal({
    title: 'Are you sure?',
    text: "You won't be able to revert this!",
    type: 'warning',
    showCancelButton: true,
    confirmButtonText: 'Yes, delete it!'
}).then(function(x) {
    this.removeNote(key);
    swal(
    'Deleted!',
    'Your file has been deleted.',
    'success'
    );
}, function(e){
       console.log('Cancelled');
});

removeNote(key){
    this.todo.remove(key);
    this.afService.closeNote(key);
}
Run Code Online (Sandbox Code Playgroud)

this.removeNote() 导致错误.

EXCEPTION: Uncaught (in promise): TypeError: Cannot read property 'removeNote' of undefined
Run Code Online (Sandbox Code Playgroud)

我该如何克服这个问题?我使用了NgZone,但我得到了同样的错误

angular

5
推荐指数
2
解决办法
6357
查看次数

从dropzone的ajax响应中获取响应文本

我从dropzone成功上传得到了以下回复.

从这里我需要获取responseText

我尝试过:console.log(response.xhr.responseText)这会显示完整的回复文字.

当我尝试img从这样的responseText中获取console.log(response.xhr.responseText.img)控制台时抛出undefined

javascript ajax dropzone.js

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

对包含在同一页面上的php函数进行ajax调用

我的问题可能听起来很旧,已经回答了你,但我没有找到令人满意的答案.让我清楚地解释我的情景,

我有这样的index.php

的index.php

<?php   
    inlcude("connect.php");   
    include("functions.php");   
?>

<html>   
    $(document).ready(function() {    
        $('#button').click(function() {    
            $.ajax({    
                type: 'GET',    
                data: 'method=test',    
                success: function(data) {    
                    alert(data);    
                }
            });    
        });    
    });
</html>
Run Code Online (Sandbox Code Playgroud)

我没有通过URL在Ajax调用,我得到了成功的数据警报但是从整个页面<html></html>.当我向functions.php提供url时,我在警告框中获得了预期的输出.

我希望你的家伙能够仔细猜测我的问题.我的问题是我需要调用一个functions.php已经包含在我的index.php页面中的函数.我不想functions.php在ajax'URL:'中再次使用,因为它functions.php会被调用两次.这是为了避免服务器负载.

让我你的家伙想出有趣的想法.

谢谢.

php ajax

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

Laravel:whereBetween 接受第一个日期

设想:

数据库中的 和 分别是和,startdate并且正常工作的查询是,enddata2015-07-202015-07-30

Model::whereBetween('startdate',array('2015-07-30','2015-08-10'))->get();
Run Code Online (Sandbox Code Playgroud)

查询从表中返回 1 条记录,这是预期结果。现在我期望的是一个小小的改变。2015-07-30考虑到日期不在中间,查询不应检索记录2015-07-30。我该如何实现这一目标?

php laravel eloquent laravel-5

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