AngularJS: Disable html button if history is empty -


in angularjs application have implemented html button "go back"-functionality . in case history empty (because user hasn't changed path since page load) want hide/disable it.

is there way detect if history empty angular?

you can check $window service of angular js. same window object of javascript.

the history object contains urls visited user (within browser window).

the history object part of window object , accessed through window.history property.

if want see whether history empty or not should use

if( $window.history.length <= 1 ) {   //internet explorer , opera start @ 0, while firefox, chrome, , safari start @ 1   console.log("empty"); } 

please make sure you've injected $window service in controller. couple of functions of history object here. can write more lines detect browser first , after apply conditions in angular way. please check post


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -