简体   繁体   English

使用AngularJS前端路由播放应用程序

[英]Play application with AngularJS frontend routing

Im using a the play framework to create a REST service and i want the front end written in Angularjs to make rest calls etc. I have set up a route provider like this: 我使用了一个play框架来创建REST服务,并且我希望用Angularjs编写的前端能够进行其他调用。我已经建立了一个路由提供者,如下所示:

angular.module("getAbscencePlans", ["getAbscencePlans.services"]).
config(function ($routeProvider) {
    $routeProvider
        .when('/plans/:companyId', {templateUrl: '/assets/views/plans.html', controller: StoryListController})
        //.when('/plans/new', {templateUrl: '/assets/views/create.html', controller: StoryCreateController})
        .when('/plans/plan/:planId', {templateUrl: '/assets/views/detail.html', controller: StoryDetailController});
});

my index page has the correct: 我的索引页面具有正确的内容:

ng-app="getAbscencePlans"

in the html tag at the top. 在顶部的html标签中。 However when i go to http://mywebsite.com/plans/2 for example i get a Action not found error. 但是,例如,当我访问http://mywebsite.com/plans/2时 ,出现“找不到操作”错误。 In my routes file i have specified a static resource for the index page, but i presumed my routeProvider would do the rest. 在我的路由文件中,我为索引页指定了静态资源,但我想我的routeProvider会做其余的事情。 What am i doing wrong :( 我究竟做错了什么 :(

Have you generated aa JavaScript router in Play? 您是否在Play中生成了JavaScript路由器? The Play router can generate JS code to handle routing from any JS client like Angular, Knockout etc and you can then select which routes to expose for JS clients. Play路由器可以生成JS代码来处理来自任何JS客户端(例如Angular,Knockout等)的路由,然后您可以选择要为JS客户端公开的路由。 To do this, follow the step-by-step instruction on Play's documentation here: https://www.playframework.com/documentation/2.1.0/ScalaJavascriptRouting 为此,请按照此处Play的文档中的分步说明进行操作: https : //www.playframework.com/documentation/2.1.0/ScalaJavascriptRouting

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM