ng:areq:解析数据Angular UI Modal

时间:2017-01-03 09:09:36

标签: javascript angularjs dependency-injection

我从控制器传递了一些数据到模态控制器。

在我的控制器中:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="NuGet" value="https://api.nuget.org/v3/index.json" />
    <add key="aspnet-contrib" value="https://www.myget.org/F/aspnet-contrib/api/v3/index.json" />
    <add key="TFS" value="https://some.pkgs.visualstudio.com/_packaging/package/nuget/v3/index.json" />
  </packageSources>
  <activePackageSource>
      <add key="All" value="(Aggregate source)" />
  </activePackageSource>
  <packageSourceCredentials>
      <TFS>
        <add key="Username" value="some@emailregisteredatvsts.nl" />
        <add key="ClearTextPassword" value="somepassword" />
      </TFS>
  </packageSourceCredentials>
</configuration>

在莫代尔工厂:

        vm.timetableModal = modals.open.timetable(vm.store.formatted_working_hours || null);
        vm.timetableModal.result.then(function (res) {
            vm.store.formatted_working_hours = res.formatted_working_hours;
        })

function timetable(current_working_hours) { return $uibModal.open({ templateUrl: 'templates/modals/timetable_modal.html', controller: 'timeTableCtrl', controllerAs: 'tm', resolve: { current_working_hours: current_working_hours } }); } 不为空时,会出现问题。

实际错误是:

  

&#34;错误:[ng:areq] http://errors.angularjs.org/1.5.8/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20Object

1 个答案:

答案 0 :(得分:0)

问题在于我必须这样做:

resolve: {
            current_working_hours: function() {
               return current_working_hours;
         }

而不是:

resolve: {
            current_working_hours: current_working_hours
         }