opening a modal in a route in AngularJS with angular-ui-bootstrap

后端 未结 4 1539
逝去的感伤
逝去的感伤 2020-12-29 13:56

I am trying to do what was essentially answered here Unable to open bootstrap modal window as a route

Yet my solution just will not work. I get an error

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 14:07

    Hi I had a hard time getting through the similar problem. However, I was able to resolve it. This is what you would probably need.

    app.config(function($stateProvider) {
      $stateProvider.state("managerState", {
          url: "/ManagerRecord",
          controller: "myController",
          templateUrl: 'index.html'
        })
        .state("employeeState", {
          url: "empRecords",
          parent: "managerState",
          params: {
            empId: 0
          },
          onEnter: [
            "$modal",
            function($modal) {
              $modal.open({
                controller: "EmpDetailsController",
                controllerAs: "empDetails",
                templateUrl: 'empDetails.html',
                size: 'sm'
              }).result.finally(function() {
                $stateProvider.go('^');
              });
            }
          ]
        });
    });
    

    Click here for plunker. Hope it helps.

提交回复
热议问题