角度引导UibModal,组件错误

时间:2017-12-12 11:00:27

标签: angularjs twitter-bootstrap angular-ui-bootstrap angularjs-components

我正在尝试使用angularcript的AngularJS 1.5组件使用角度引导程序UibModal。

我已经定义了组件,组件的控制器是一个类。现在,当我执行$ uibModal.open(...)时,它会找到组件但无法加载控制器。它失败并出现此错误

"Error: [$injector:unpr] Unknown provider: Provider <-  <- TempController"

我的代码如下: -

组件: -

 export function TempComponent(): ng.IComponentOptions {
  return {
    bindings: {
      resolve: '<',
      close: '&',
      dismiss: '&'
    },
    controller: TempController,
    controllerAs: 'vm',
    template: require('./Temp.html')
  };
}


angular
  .module('moduleName')
  .component('tempComponent', TempComponent());

控制器: -

export class TempController {

  public static $inject: string[] = [''];

  public someData: string;

  public resolve?: { [key: string]: string | Function | Array<string | Function> | Object };

  public close: Function;
  public dismiss: Function;


  public $onInit(): void {
    this.someData= <string>this.resolve.someData;
  }

  public ok(): void {
    this.close();
  }

  public cancel(): void {
    this.dismiss('cancel');
  }
}

angular.module('moduleName')
  .controller('tempController', TempController);

使用UIBModal: -

$uibModal.open({component: tempComponent, resolve: .......})

任何人都可以指导我做错了吗?

0 个答案:

没有答案