在url中添加一个参数(angularjs)

时间:2018-02-15 10:16:04

标签: angularjs angularjs-1.6

我希望能够在点击后将参数保存在url中。

当我在离线页面上时,我有这个网址:

  

http://localhost:3000/feliway-coupon?src_org=166

我希望连接后也能使用相同的一个。但是,参数不会保留。这就是连接之后:

  

http://localhost:3000/feliway-coupon

我希望此参数(<button ng-click="$ctrl.onConnect()">connect</button> )保持

HTML:

onConnect() {
  const search = this.$location.search().src_org

  if (search === '166') {
    this.$location.state().search('src_org', '166')
  }
}

JS:

BluetoothService

我想知道$ location是否可以解决这个问题?或者通过其他方法,但不使用ui-router或ng-route。

0 个答案:

没有答案