【问题标题】:ng-admin file uploadInformation get entity idng-admin 文件uploadInformation 获取实体id
【发布时间】:2016-06-10 09:35:07
【问题描述】:

在 ng-admin 编辑视图中,我需要更改带有 id 的文件上传 url,如下所示,但我不知道如何在 uploadInformation 基础 url 中获取所选实体的 id,例如 {{entry.values.id}}是我的代码:

files.editionView()
            .title('Edit File {{ entry.values.id }}({{       entry.values.filePath}})') // title() accepts a template string, which has  access to the entry
            .actions(['list', 'show', 'delete']) // choose which buttons appear in the top action bar. Show is disabled by default
            .fields([
                nga.field('id').label('id').editable(false),
                nga.field('file', 'file').uploadInformation({ 'url': baseurl     +"files/upload/{{entry.values.id}}"}),// fields() without arguments returns the list of fields. That way you can reuse fields from another view to avoid repetition    
            ])

【问题讨论】:

    标签: angularjs restangular ng-admin


    【解决方案1】:

    {{ entry.values.id }} - 是一个 Angular 表达式,这种形式应该用于 HTML 而不是 JavaScript。 我假设 entry 是您的 $scope 变量,因此您需要编写如下内容:... .uploadInformation({ 'url': baseurl+ "files/upload/"+$scope.entry.values.id})

    $scope.entry 应该预先填充到控制器的代码中

    【讨论】:

    • 我在 app.config() 中使用了这段代码。我是 Angular 的初学者,所以不知道如何在那里访问 $scope。
    • 我的建议是参加一些入门课程,例如这里:Learn AngularJS。将为您节省大量时间
    猜你喜欢
    • 2019-08-01
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 2012-11-10
    • 2017-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多