javascript - AngularJS, $window is not defined, how to? - Stack Overflow

i am trying to do a redirect on a click.controller('TestCtrl', function ($scope, $stateParams

i am trying to do a redirect on a click

.controller('TestCtrl', function ($scope, $stateParams) {
    document.getElementById('next_question').addEventListener('click', function (e) {
        $window.location.href = '#/tab/category/1';
        return true;
    }, false);
})

but i get $window is not defined. So... how would i get the $window or do a redirect a different way

any ideas?

i am trying to do a redirect on a click

.controller('TestCtrl', function ($scope, $stateParams) {
    document.getElementById('next_question').addEventListener('click', function (e) {
        $window.location.href = '#/tab/category/1';
        return true;
    }, false);
})

but i get $window is not defined. So... how would i get the $window or do a redirect a different way

any ideas?

Share Improve this question asked Apr 26, 2014 at 23:02 PatrioticcowPatrioticcow 27.1k76 gold badges221 silver badges339 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 5

$window needs to be included as an argument so that it can be injected...

.controller('TestCtrl', function ($scope, $stateParams, $window) {
    document.getElementById('next_question').addEventListener('click', function (e) {
        $window.location.href = '#/tab/category/1';
        return true;
    }, false);
})

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742167628a4394509.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信