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 70 posts 247 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 839 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 1938 posts 5866 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!

Please Sign in or register to post replies

Write your reply to:

Draft