Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Aki 43 posts 214 karma points
    Aug 17, 2017 @ 11:55
    Aki
    0

    Angular set New dataType with view and Undefined value

    HI im trying to make a Datatype with a dataview. A Textarea is used to display Json.

    i have a temp $scope.model.Json

    $scope.model.Json = JSON.stringify($scope.model.value.Json, undefined, 2);
    

    which is parsed to the original value with JSlint

    $scope.model.value.Json = jsonlint.parse($scope.model.Json);
    

    Now if the $scope.model.value.Json is undefined i cant get the scope to update... how do i force this value to update??

    i tryied to assign it but it does not update

     if ($scope.model.value.Json === undefined) {
                console.log("default value");
                $scope.model.value.Json = {};
            } else {
                $scope.model.Json = JSON.stringify($scope.model.value.Json, undefined, 2);
            }
    
  • Aki 43 posts 214 karma points
    Aug 17, 2017 @ 13:28
    Aki
    100

    Found the solution need to initilize the value it it was undefined

    if ($scope.model.value === '') {
        $scope.model.value = {};
    }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies