使用$ routeProvider时无法调用函数

时间:2016-10-09 23:38:42

标签: html angularjs

我有一个带有<div ng-view></div>块的索引页面。这里使用$routeProvider插入了各种模板。

$routeProvider
    // route for the home page
        .when('/', {
            templateUrl: 'templates/home.html',
            controller: 'mainController',
            css: 'css/style.css'
        })
        // route for the report page
        .when('/report', {
            templateUrl: 'templates/report.html',
            controller: 'reportController',
            css:['css/results.css','css/chart.css']
        })
        // route for the admin panel
        .when('/adminpanel', {
            templateUrl: 'templates/admin.html',
            controller: 'adminController'
        })

在其中一个模板中,我有一个表单,在提交时使用Angular ng-click="processPdf()"调用一个函数。

<div class="remodal" data-remodal-id="download" role="dialog">
    <button data-remodal-action="close" class="remodal-close"></button>
    <h4 class="factor-title">Download Your PDF</h4>
    <div class="window-message">
        <form class="remodal-form" name="download-pdf" id="download-pdf">
            <input type="email" placeholder="Enter your email" name="download-email" id="email" required>
            <button ng-click="processPdf()" type="submit" class="download"><i class="fa fa-file-pdf-o fa-3x"></i> <span>Download PDF</span></button>
        </form>
        <button class="back-fixit" data-remodal-target="fixit"><i class="fa fa-long-arrow-left"></i> Back</button>
    </div>
</div>

问题在于,一旦我调用它,它就会提供无效路径:即使在报告模板上使用了该函数,它也会生成/report/?email=zzz.com而不是?email=zzz.com/report。我不知道该怎么做,我们将不胜感激。

0 个答案:

没有答案
相关问题