angular.js - angularjs 时间控件点击后更改url

【字号: 日期:2023-01-25浏览:23作者:雯心

问题描述

我在想 点击时间控件后,该时间参数能够带到url中 0 0。。。有什么方法?求教。。找了好久了

问题解答

回答1:

将时间控件中的参数手动添加到url中不就可以了。。。

你看一看看示例

<body ng-app='MyApp'><h1>Time Show</h1><p ng-controller='MyController as vm'> <input type='time' ng-model='vm.time'/> <button ng-click='vm.change()'>添加参数到url</button></p><script> angular.module(’MyApp’,[]) .controller(’MyController’, MyController); MyController.$inject = [’$http’,’$location’]; function MyController($http, $location){var vm = this;vm.change = change;vm.params = { time: ’3600’ // 这里你可能要对你获取到的时间做一下处理,我就简单写一下.};function change(){ console.log(vm.time); var url = ’https://api.github.com/users’; $http.get(url, {params: vm.params}) .then(function(res){console.log(res); })} }</script></body>

不知道你的想法是不是这样,当你获取到时间后,要与后端进行交互,而其中的时间是查询参数。

相关文章: