search

Home  >  Q&A  >  body text

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

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

怪我咯怪我咯2744 days ago585

reply all(1)I'll reply

  • 给我你的怀抱

    给我你的怀抱2017-05-15 16:58:20

    Isn’t it enough to manually add the parameters in the time control to the url? . .


    Take a look at the example

    <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>

    I don’t know if this is what you think. After you get the time, you need to interact with the backend, and the time is a query parameter.

    reply
    0
  • Cancelreply