javascript - ng hide, how to conditionally show something in angular with url extension -
I'm testing and app and want to do something very simple. I would like to hide a device and show it in the browser only when an extension will be added to the URL. For example:
& lt; Div ng-hide = "true" class = "cookie-banner" & gt; Warning you about cookies & lt; / Div & gt; Adding me to hidden division - & gt; Show = URL cookie-Banner, a local site like: ../webapp/#/subscribed not show Divijh hidden, but ../webapp/#/subscribed?show=cookie-banner it. I am not sure what I am making to work on this. help please!
You can use it in your own controller or in a custom command you create, where you like $$ absUrl value to set your logic based on $$
// in your controller app.controller ( 'SomeController', [ '$ scope', '$ location', function ($ radius, $ location) {$ scope.hideBasedOnUrl = $ Area $$ absUrl.indexOf ('show = cookie-banner')! == -1;}]); // html & lt; Div ng-hide = "hideBasedOnUrl" class = "cookie-banner" & gt; Warning you about cookies & lt; / Div & gt; // directive Appkdirective ( "HideBasedOnUrl", function ($ location) {return {restricted: "E" link: function (scope, elements, attrs, ngModelCtrl) {if ($ location. $$ absUrl.indexOf ( ' Show = cookie-banner ')! == -1) {element.style.display = "none";}}}}); // html & lt; Div hideBasedOnUrl class = "cookie-banner" & gt; Warning you about cookies & lt; / Div & gt; With the instructions you can further enhance such as pass url value in html when you want to hide the device. Hope it helps!
Comments
Post a Comment