简体   繁体   English

AngularJS没有加载“详细视图”数据

[英]AngularJS not loading “detail view” data

I have a list of items, which I want to be able to click on to load the detail view: foo/123 . 我有一个项目列表,我希望能够单击它以加载详细视图: foo/123 My $stateProvider variable defines ... }) .state('foo', { url: '/foo/:fooId', templateUrl: 'client/templates/foo.html', controller: 'FooViewCtrl as foo', }); 我的$stateProvider变量定义了... }) .state('foo', { url: '/foo/:fooId', templateUrl: 'client/templates/foo.html', controller: 'FooViewCtrl as foo', });

fooview.controller.js: fooview.controller.js:

angular
  .module('AppName')
  .controller('FooViewCtrl', FooViewCtrl);

function FooViewCtrl ($scope, $reactive, $stateParams) {
  $reactive(this).attach($scope);

  let fooId = $stateParams.fooId;

  this.helpers({
    data() {
      var a = Data.findOne(fooId); //Meteor func
      console.log(a); //this runs and correctly outputs the object
      return a;
    }
  });
}

foo.html: foo.html:

<ion-view title="{{foo.name}}">
  <ion-content>
    <p>{{foo.name}}</p>
  </ion-content>
</ion-view>

What am I missing here? 我在这里想念什么? Am I correct in thinking that the data function returns something "as foo" which is then referenced as foo in foo.html? 我是否正确认为数据函数返回“ as foo”,然后在foo.html中将其引用为foo

Since you used controllerAs think it might look like 由于您使用controllerAs认为它可能看起来像

<ion-view title="{{foo.data.name}}">
  <ion-content>
    <p>{{foo.data.name}}</p>
  </ion-content>
</ion-view>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM