使用angularjs

时间:2017-12-21 05:17:20

标签: javascript angularjs json function

我使用两个功能来存储开始停止时间,  使用此代码,

$scope.start = function(data) {

    $scope.time = {
        id: '',
        mainId: data.id,
        start: ''
    }
    $scope.Mydata = data;

    function startTime() {
        $http.post('/api/timestart', $scope.time).then(function(response) {

        });
    }
    startTime();

}



$scope.stop = function(data) {
    $scope.time = {
        id: '',
        mainId: data.id,
        start: '',
        stop: moment(new Date())
    }


    $scope.Mydata = data;

    function stopTime() {
        $http.post('/api/timestop', $scope.time).then(function(response) {

        });
    }

    stopTime();
}

我想要回归&将start()函数数据传递给stop()函数。

使用angularjs将数据传递到同一个控制器中的另一个函数。

2 个答案:

答案 0 :(得分:0)

只需致电 $scope.stop()

function startTime() {
        $http.post('/api/timestart', $scope.time).then(function(response) {
            $scope.stop(response);
        });
}

答案 1 :(得分:0)

您已在函数内创建了函数。请删除功能startTime(){}& function stopTime() {}& $scope.start()内的$scope.stop() $scope.start = function(data) { $scope.time = { id: '', mainId: data.id, start: '' } $scope.Mydata = data; $http.post('/api/timestart', $scope.time).then(function(response) { $scope.stop(response); }); } $scope.stop = function(data) { $scope.time = { id: '', mainId: data.id, start: '', stop: moment(new Date()) } $scope.Mydata = data; $http.post('/api/timestop', $scope.time).then(function(response) { }); } 函数。

您的代码应该像

Declare @charToFind varchar(3) = '1'
Declare @Ocurrences int = 6, @result INT

SELECT @result = 
COUNT(COALESCE(LEN(ANIO_1) - LEN(REPLACE(ANIO_1,@charToFind,'')), 
LEN(ANIO_1), 0))
FROM 
#MATRIZ_HISTORICO_PAGOS
WHERE 
COALESCE(LEN(ANIO_1) - LEN(REPLACE(ANIO_1,@charToFind,'')), LEN(ANIO_1), 0) = @Ocurrences

SELECT CASE WHEN @result > 0 THEN 'OK' ELSE 'NO MATCH' END