Copied to clipboard

Flag this post as spam?

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


  • Paul Sørensen 304 posts 650 karma points
    Dec 29, 2015 @ 19:53
    Paul Sørensen
    0

    ngResource problem

    Hi I'm trying to develop a custom section where I use Angular. I would like to use ngResource but if I include it I get

    No module: ngResource

    The only angular I have included is this

    angular.module("umbraco.resources",
                    ["ngRoute", "ngResource"])
        .constant("appSettings",
        {
            serverPath: "backoffice/Caddie/ResultTree"
        });
    

    Do I have to load angular-resources.js or is something else wrong here ?.

    /Paul S

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Dec 29, 2015 @ 20:09
    Nicholas Westby
    0

    Yes, it looks like ngResource requires a second script file to be included in order to use it: https://docs.angularjs.org/api/ngResource

    <script src="angular.js">
    <script src="angular-resource.js">
    

    You can do that in the package manifest for your custom section: http://umbraco.github.io/Belle/#/tutorials/manifest

    Since other packages might potentially use this same JavaScript file, I wonder if there might be some way to only include that if isn't already included by another package.

  • Paul Sørensen 304 posts 650 karma points
    Dec 30, 2015 @ 13:54
    Paul Sørensen
    1

    Hi Thansk for tha answer

    Just found it strange that I had to do this because it's included in the Umbraco release.

    I also had other problems including the ngResource module but finally found a way if anyone else are having problems with the module.

    var app = angular.module("umbraco");
    
    //Only need to inject/requires the ngResource module once
    //As when done all other controllers will have access to it
    app.requires.push('ngResource');
    
    angular.module("umbraco.resources")
        .constant("appSettings",
        {
            serverPath: "backoffice/Caddie/ResultTree"
        });
    

    /Paul S

Please Sign in or register to post replies

Write your reply to:

Draft