AngularJs 1.5 $location获取url参数


地址:http://localhost/waservice.html?id=17

 

获取参数id的值

 

 app.config(['$locationProvider', function ($locationProvider) {

            $locationProvider.html5Mode({
                enabled:  true,
                requireBase:  false //必须配置为false,否则<base href=''>这种格式带base链接的地址才能解析
            });
        }]);
       
        app.controller( ' userController ', [ ' $scope '' $location ', function ($scope, $location) {
            alert($location.search().id);
             if ($location.search().id) {
                $scope.keyword = $location.search().id;
            }
        }]);

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM