Copied to clipboard

Flag this post as spam?

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


  • Anton Oosthuizen 206 posts 486 karma points
    Sep 30, 2019 @ 19:30
    Anton Oosthuizen
    0

    Umbraco 8 Section with custom plugin

    Good Day,

    I am at wits end with this problem.

    I have created a section with a plugin as follows : enter image description here

    With the following controller :

    angular.module("umbraco")
    .controller("QuotesAndOrdersController", function ($scope ) {
    
        $scope.test = "test";
    
    });
    

    And the following view :

    <umb-panel ng-controller="QuotesAndOrdersController">
    <h1>Test</h1>
    <p> My test :{{test}} </p> 
    

    And the following tree controller

     [Tree("QuotesAndOrders", "Orders", IsSingleNodeTree = true, TreeTitle = "Quotes and Orders",
        TreeGroup = "quotesAndOrdersGroup", SortOrder = 5)]
    [PluginController("QuotesAndOrders")]
    public class QuotesAndOrdersTreeController : TreeController
    {
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
           return new TreeNodeCollection();
        }
    
        protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
        {
             return new MenuItemCollection();
        }
    
        protected override TreeNode CreateRootNode(FormDataCollection queryStrings)
        {
            TreeNode root = CreateTreeNode("-1", "-1", queryStrings, "Quotes and Orders", "icon-chart-curve", false);
    
            root.RoutePath = $"QuotesAndOrders/{TreeAlias}/orders";
    
            return root;
        }
    

    My problem is if you look at the controller $scope.test = "test";

    The controller Executes and the html displays but {{test}} remains empty.

    Some extra eyes will be a great help

  • Marc Goodson 2157 posts 14431 karma points MVP 9x c-trib
    Sep 30, 2019 @ 22:21
    Marc Goodson
    100

    Hi Anton

    I think it is possibly an issue with your view try:

    <div ng-controller="QuotesAndOrdersController">
    
            <h1>Test</h1>
            <p> My test :{{test}} </p>
    
    </div>
    

    but do also make sure you have a package.manifest file in your app_Plugins folder that will tell Umbraco to load the javascript resource that contains your controller... eg

    {
        javascript: [
            '~/App_Plugins/QuotesAndOrders/QuotesAndOrdersController.js'
        ]
    }
    

    but I think you've probably got that otherwise you'd be seeing an error in the console about it not being defined!

    anyway try a div instead of umb-panel directive, I don't think the directive is expecting ng-controller to be defined...

    regards

    Marc

  • Anton Oosthuizen 206 posts 486 karma points
    Oct 01, 2019 @ 02:34
    Anton Oosthuizen
    1

    Mark, you're a genius. You saved my ass. It was indeed the controller in the umb-panel. I wrapped that in a div and all works as it is supposed to.

Please Sign in or register to post replies

Write your reply to:

Draft