简体   繁体   中英

In Angular, What does it mean $location.path() == '/a'?

I am new to AngularJs and I am going through Angular documentation to understand it. I recently encountered this this code $location.path() == '/a' , but I fail to understand what does it mean and what it does. In this example == is used as a assignment operator? So can anyone explain me what difference will it make? Is it angular specific or it means something in Javascript as well.

    it('should show example', inject(
  function($locationProvider) {
    $locationProvider.html5Mode(false);
    $locationProvider.hashPrefix('!');
  },
  function($location) {
    // open http://example.com/base/index.html#!/a
    $location.absUrl() == 'http://example.com/base/index.html#!/a'
    $location.path() == '/a'

    $location.path('/foo')
    $location.absUrl() == 'http://example.com/base/index.html#!/foo'

    $location.search() == {}
    $location.search({a: 'b', c: true});
    $location.absUrl() == 'http://example.com/base/index.html#!/foo?a=b&c'

    $location.path('/new').search('x=y');
    $location.absUrl() == 'http://example.com/base/index.html#!/new?x=y'
  }
));

This entire code is from the angular docs .

It's just showing you that in hashBang mode if you have the url http://example.com/base/index.html#!/a

$location.absUrl() will be 'http://example.com/base/index.html#!/a'

(ie $location.absUrl() == 'http://example.com/base/index.html#!/a' is true )

Same with $location.path() will be '/a'

( $location.path() == '/a' is true )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM