如何在角度材料中将数据传递给 $mdDialog [英] How pass data to $mdDialog in angular material

查看:23
本文介绍了如何在角度材料中将数据传递给 $mdDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一些数据传递给 $mdDialog.事实上,我在一个单独的文件中有两个控制器.这是我的控制器代码

I want to pass some data to $mdDialog. In fact, I have two controllers in a separate file. Here is my controller code

function openDialog(id) {
        $mdDialog.show({
            locals:{
                profileId: id
            },
            controller: ['$scope', 'profileId', function($scope, profileId) {
              var self = this;
                self.profileId= profileId;
            }],
            controllerAs: 'profileCtrl',
            templateUrl: 'view/profile.html',
            parent: angular.element(document.body),
            clickOutsideToClose:true

        })
    }

我希望 tp 将 profileId 传递给 profileController 并显示配置文件数据.在配置文件控制器中,我获得了这样的数据

I want tp pass profileId to profileController and display profile data. In profile controller i get data as this

function profileController($scope,..., profileId){

}

但是这个错误出现在控制台

but this error apear in console

  Error: [$injector:unpr] Unknown provider: profileIdProvider <- profileId<- ProfileController

这是什么错误以及如何修复它?

what is this error and how to fix it?

推荐答案

我在配置文件模板中添加了 ng-controller="ProfileController as profileController" ,这是由于错误造成的.通过删除它,我的问题解决了.

I added ng-controller="ProfileController as profileController" in profile template and this was due to an error. By removing it my problem solved.

这篇关于如何在角度材料中将数据传递给 $mdDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆