Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs ng从bootstrap popover提交_Angularjs_Twitter Bootstrap_Twitter Bootstrap 3 - Fatal编程技术网

Angularjs ng从bootstrap popover提交

Angularjs ng从bootstrap popover提交,angularjs,twitter-bootstrap,twitter-bootstrap-3,Angularjs,Twitter Bootstrap,Twitter Bootstrap 3,下面的jade模板在popover中显示登录表单loginForm。同样的表单标记在管线中作为视图的一部分呈现时可以正常工作,但是当按照下面的代码放置到popover中时,ng submit不起作用。表单的提交在当前位置生成GET提交 doctype html html(lang='en', data-ng-app='angular-client-side-auth') head meta(charset='utf-8') title Whatever

下面的jade模板在popover中显示登录表单loginForm。同样的表单标记在管线中作为视图的一部分呈现时可以正常工作,但是当按照下面的代码放置到popover中时,ng submit不起作用。表单的提交在当前位置生成GET提交

doctype html
html(lang='en', data-ng-app='angular-client-side-auth')
    head
        meta(charset='utf-8')
        title Whatever

        //- CSS
        link(rel='stylesheet', href='/css/app.css')
        link(href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css", rel="stylesheet")
        link(href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css", rel="stylesheet")

        //- This is needed because Facebook login redirects add #_=_ at the end of the URL
        script(type="text/javascript").
            if (window.location.href.indexOf('#_=_') > 0) {
                window.location = window.location.href.replace(/#.*/, '');
            }

    body(data-ng-cloak)

        .container
            .container.navbar.navbar-inverse.navbar-fixed-top(data-ng-controller="NavCtrl")
                ul.navbar-nav.nav(data-access-level='accessLevels.anon', active-nav)
                    li: a.navbar-brand(href="/") Whatever
                ul.navbar-nav.nav.pull-right(data-access-level='accessLevels.anon', active-nav)
                    li: a(href="#" id="loginLink") Log In

                ul.navbar-nav.nav(data-access-level='accessLevels.user', active-nav)
                    li: a.navbar-brand(href="/home") Quiver
                ul.navbar-nav.nav.pull-right(data-access-level='accessLevels.user', active-nav)
                    li.dropdown
                        a.dropdown-toggle(href="#", data-toggle="dropdown")
                            |{{user.username}} <b class="caret"></b>
                        ul.dropdown-menu
                            li: a(href="/u/{{user.username}}") Your Profile
                            li: a(data-ng-click="logout()") Log Out

            .alert.alert-danger(id='error', data-ng-bind="error", data-ng-show="error")

            div.content(id='content', data-ng-view='ng-view')

        #login.hide
            form.form-horizontal(ng-controller="LoginCtrl", ng-submit="login()", id="loginForm", name="loginForm", role="form", autocomplete="off")
                input(type="hidden", data-ng-model="foo", value="bar")
                .form-group
                    input.form-control(type="text", data-ng-model="username", placeholder="Username", name="username", required, autofocus)
                .form-group
                    input.form-control(type="password", data-ng-model="password", placeholder="Password", name="password", required)
                .form-group
                    input(type="checkbox", data-ng-model="rememberme", name="rememberme")
                    | &nbsp;Remember me
                .form-group
                    button.btn.btn-default(type="submit") Log in

        //- JavaScript
        script(src='//code.jquery.com/jquery-1.10.1.min.js')
        script(src='//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js')
        script(src='//ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js')
        script(src='//ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular-cookies.min.js')
        script(src='//ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular-route.min.js')
        script(src='//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js')
        script(src='/js/routingConfig.js')
        script(src='/js/app.js')
        script(src='/js/services.js')
        script(src='/js/controllers.js')
        script(src='/js/filters.js')
        script(src='/js/directives.js')

        script(type="text/javascript").
            $(document).ready(function() {
                $('#loginLink').popover({
                    placement:'bottom',
                    template: '<div class="popover" style="margin-left:-70px; margin-top:-5px;"><div class="arrow" style="margin-left:60px"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>',
                    html : true, 
                    content: function() {
                      return $('#login').html();
                    }
                });
            });


        //- Partial views... Load up front to make transitions smoother
        script(type="text/ng-template", id="404")
            include partials/404
        script(type="text/ng-template", id="index")
            include partials/index
        script(type="text/ng-template", id="login")
            include partials/login  

我假设表单不在范围内。可以做些什么

你试过使用$rootScope吗?不知道我会在哪里使用,@aikutto。在LoginCtrl中?对不起,我对棱角分明的人很陌生。您可以在LoginCtrl中访问$rootScope.username。@aikutto好的,我理解。但是,表单没有绑定到控制器。它实际上提交了一个带有URL中输入值的GET请求。它只在像路由一样交付到content div时才起作用。我不想要路由,我想要表单出现在popover中,并且仍然绑定到控制器。