Copied to clipboard

Flag this post as spam?

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


  • Paul McCarthy 39 posts 160 karma points
    Apr 05, 2019 @ 10:28
    Paul McCarthy
    0

    Link Picker in back office not updating angular $scope

    I have added a custom section on the back office to build a short url app and am using dialogService to call the form

     dialogService.open({
                template: '../App_Plugins/UrlShortener/CreateURL.html',
                show: true,
                dialogData: '',
                callback: done
            });
    

    In the template, I call a link picker

     <ul class="unstyled list-icons">
                            <li>
                                <i class="icon icon-add blue"></i>
                                <a class="btn btn-link btn-small linkPickFunc" ng-click="openLinkPicker()">Select</a>
    </li>
                        </ul>
    

    That function in turn opens a link picker and returns the url value when you select an item from the content tree

     $scope.openLinkPicker = function () {
            dialogService.linkPicker(
                {
                    callback: populateLink
                });
    
    
    
        function populateLink(item) {
            $scope.node = item;
            $scope.BaseUrl = item.url;
            var burl = document.getElementById("BaseUrl");
            burl.value = item.url;
            }  
    };
    

    This does add the url to $scope.BaseUrl (I've checked by logging it to console) but the angular form doesn't validate, so that field remains ng-pristine and when the form submits that value is null. I've even tried adding the value in in javascript as above. Have tried forcing that field to focus, blur, nothing works.

    When I try $scope.$apply() or $digest() it throws the '$apply is already in progress' error. Trying to $SetDirty or anything like that also throws an error that 'this is not a function'.

    Can anyone suggest anything?

Please Sign in or register to post replies

Write your reply to:

Draft