Click here to Skip to main content
16,021,687 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
HI
i wants to convert a angularjs javascript code into typescript. following is the code snippet
$scope.sortableOptions = {
    update: function (e, ui) {
        var logEntry = tmpList.map(function (i) {
            return i.value;
        }).join(', ');
        $scope.sortingLog.push(logEntry);
    },
    stop: function (e, ui) {
        // this callback has the changed model
        var logEntry = tmpList.map(function (i) {
            return i.value;
        }).join(', ');
        $scope.sortingLog.push(logEntry);
    }
};


can any buddy help me to convert this code into typescript. i am new in typescript.

Regards
Posted
Updated 13-Oct-20 19:35pm
Comments
Suvendu Shekhar Giri 19-Nov-15 2:06am    
Have you tried anything?

 
Share this answer
 
Comments
AshishSarang 19-Nov-15 2:11am    
Thanks. this helps me..
(function() {

    "use strict";

    angular.module("jwtWebApp")
        .controller("LoginCtrl",
        [
            "$scope", "$window", "$http", "$state",
            function($scope, $window, $http, $state) {

                var storage = $window.localStorage;

                $scope.submit = function() {

                    var user = {
                        email: $scope.email,
                        password: $scope.password
                    };

                    //Check for token
                    if (!storage.getItem("jwt_token")) {
                        $http.post("signin", user)
                            .success(function(res) {
                                $window.localStorage.setItem("jwt_token", res.token);
                                $state.go("books");
                            })
                            .error(function(err) {
                                console.log(err);
                            });
                    }

                };

            }
        ]);

})();
 
Share this answer
 
Comments
Member 12973816 10-Oct-17 2:48am    
Can you please help me write this JavaScript code to TypeScript


function base64url(source) {

encodedSource = CryptoJS.enc.Base64.stringify(source);


encodedSource = encodedSource.replace(/=+$/, '');


encodedSource = encodedSource.replace(/\+/g, '-');
encodedSource = encodedSource.replace(/\//g, '_');

return encodedSource;
}
you can use aicodeconvert.com,and it is free.


TypeScript
$scope.sortableOptions = {
    update: (e: any, ui: any) => {
        let logEntry = tmpList.map((i: any) => {
            return i.value;
        }).join(', ');
        $scope.sortingLog.push(logEntry);
    },
    stop: (e: any, ui: any) => {
        // this callback has the changed model
        let logEntry = tmpList.map((i: any) => {
            return i.value;
        }).join(', ');
        $scope.sortingLog.push(logEntry);
    }
};
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900