小编Har*_*rry的帖子

$ watch只触发一次

我正在为AngularJS 使用智能表(http://lorenzofox3.github.io/smart-table-website/),并且我创建了一个名为isReset的标志,它将触发表重新加载.发生这种情况是因为我有一个指令正在观察该标志,并且在设置了isReset时将运行刷新,并且在完成刷新之后,它将再次设置该标志.

我的问题是,当我设置标志时,它会第一次运行,但在监视标志的行为后,似乎永远不会将其设置为false.我尝试手动将标志设置为false,但下次$ watch甚至没有触发.我的代码如下,如果你可以帮助我解决这个问题,那就太好了.最奇怪的是,我有另一个地方,我以完全相同的方式使用它,它按预期工作.

JS

        $scope.resetFilter = function() {
        $scope.timestampFilter = "";
        $scope.levelFilter = "";
    };

    $scope.getAPIServerLogs = function (tableState) {
        $scope.isLoading = true;
        ServerLog.get({
            "serverType": "API",
            "timestampFilter": $scope.timestampFilter,
            "levelFilter": $scope.levelFilter,
            "offset": tableState.pagination.start,
            "limit": tableState.pagination.number,
            "sortField": tableState.sort.predicate,
            "order": tableState.sort.reverse ? "desc" : "asc"
        }, function (response) {
            $scope.isLoading = false;
            $scope.serverlogs = response.data;
            $scope.displayedserverlog = [].concat($scope.serverlogs);
            tableState.pagination.numberOfPages = response.pages;
        });
    };
Run Code Online (Sandbox Code Playgroud)

指示

directives.directive('stReset', function () {
return {
    require: '^stTable',
    replace: false,
    scope: {stReset: "=stReset"},
    link: function (scope, …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs angularjs-directive smart-table

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

Difference between nums[:] = nums[::-1] and nums = nums[::-1]

I'm currently learning Python and I encountered an issue with with assignment to a list.

In

def nextPermutation(self, nums: List[int]) -> None:
    ...
Run Code Online (Sandbox Code Playgroud)

I have a line of code that reverses the list as follows:

nums = nums[::-1]
Run Code Online (Sandbox Code Playgroud)

but the test bench marks it as incorrect, whereas

nums[:] = nums[::-1]
Run Code Online (Sandbox Code Playgroud)

is ok.

I suspect it's because I'm creating another nums list object and the original list that's passed in is unchanged, is that right?

python python-3.x

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