Copied to clipboard

Flag this post as spam?

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


  • Nathan Woulfe 447 posts 1665 karma points MVP 5x hq c-trib
    Sep 28, 2015 @ 06:28
    Nathan Woulfe
    0

    Adding conditional controller to property editor

    I'm working on an editor in which I need to be able to define a custom view and controller as config items, then load these if the config items exist.

    I'm storing each as a path to the view/controller, then loading the controller using assetsService, and setting the path in a call to dialogService.open to the view path from the config.

    View works fine, it opens the custom view as the dialog. Issue is the controller - it loads (I see the promise resolve) but throws an AngularJs error where the controller is not a function.

    Is it possible to define the path to the controller, load the file using assetsService, then have it resolve correctly when I render the view?

    if ($scope.model.config.customController !== undefined) {
        assetsService.loadJs($scope.model.config.customController);
    }
    
    dialogService.open({
        template: $scope.dialogPath,
        show: true
    }
    

    Is this even possible?

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 02, 2015 @ 06:52
    Dave Woestenborghs
    0

    I know this can be done with angular but it requires to change routing and other things.

    I know Andy Butland was trying something similar in his Personalisations Group package.

    Maybe you can have a look at his source to see if he found a solution. https://github.com/AndyButland/UmbracoPersonalisationGroups

    Dave

  • Nathan Woulfe 447 posts 1665 karma points MVP 5x hq c-trib
    Oct 02, 2015 @ 07:32
    Nathan Woulfe
    0

    Thanks Dave - I took the easy way out. Figure if a user is having to add a controller, they can also register it in the package manifest. Would have been nice to not have to, but the end result is the same.

Please Sign in or register to post replies

Write your reply to:

Draft