从url获取参数

时间:2014-04-07 15:54:27

标签: ember.js

在我的余烬应用中,用户可以在路线' /#/ pm /:program_id / projects / new'创建新项目。其中':program_id'是一个可以改变的变量。项目属于某个程序,因此我创建的每个项目都需要该关联。如何访问调用路由的程序?

编辑评论:

App.ProjectsNewRoute = Ember.Route.extend
  model: ->
    @store.createRecord 'project'

  deactivate: ->
    @currentModel.rollback()

-

App.ProjectsNewController = Ember.ObjectController.extend
  statuses: ["Active", "Attrited", "Dropped", "Completed"]
  actions:
    submit: ->
      project = @get('model')
      @get('model').save().then(@onCreate.bind(@), @onFail.bind(@))

  onCreate: ->
    @transitionToRoute('projects.index')

  onFail: ->
    console.log 'failure'

-

App.Router.map ->

  @resource 'su', ->
    @resource 'programs', ->
      @route 'new'
      @route 'edit', path: ':program_id/edit'

    @resource 'users', ->
      @route 'new'
      @route 'edit', path: ':user_id/edit'

    @resource 'availability', ->
      @resource 'availability.show', path: ':program_id', ->
        @route 'details', path: 'details/:user_id'

  @resource 'pm', path: 'pm/:program_id', ->
    @resource 'projects', ->
      @route 'new'
      @route 'edit', path: ':project_id/edit'

0 个答案:

没有答案