Copied to clipboard

Flag this post as spam?

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


  • Ulf Möllerström 71 posts 248 karma points
    Sep 28, 2021 @ 19:37
    Ulf Möllerström
    0

    Angular: get the current nodes url

    Hi folks! Trying to get the url for the current node in a content-app: the urls are listed in a collection named currentUrls (?), but where do I find it in the controller?

    The url is to be displayed in an iframe in the content-app.

  • Johannes Lantz 156 posts 840 karma points c-trib
    Sep 28, 2021 @ 19:45
    Johannes Lantz
    1

    Hi Ulf!

    I think you could use $location

    Eg.

    angular.module("umbraco").controller("controller", function ($location) { 
        console.log($location.$$url)
    }
    

    //Johannes

  • Markus Johansson 1945 posts 5899 karma points MVP 2x c-trib
    Sep 28, 2021 @ 21:26
    Markus Johansson
    2

    $location would give you the current URL in the browser (to the backoffice item) but are you looking for the frontend URL to the content item?

    Have a look at injecting the editorState into your controller, example:

    https://github.com/enkelmedia/Umbraco-SeoVisualizer/blob/v9/SeoVisualizer/App_Plugins/SeoVisualizer/SeoVisualizerController.controller.js

    Basically injecting it and use:

    var allUrls = editorState.getCurrent().urls

    Also note that a page can have multiple urls, depending on language/host name settings.

    Cheers!

  • 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