Access a object from a Collection does not work on pageload


#1

Hi all

I have a strange bug. When I click a link with

 <button ui-sref="anlass({anlass: anl._id})">

I get a object in the constructor.

But when I change the source and meteor does a pageload, It does not work. Can anyone help me?

Regards


import angular from 'angular';
import angularMeteor from 'angular-meteor';
import uiRouter from 'angular-ui-router';
import { Anlaesse } from '../../../../collections/anlaesse';

import './anlass.html';

const name = 'anlass';


class Anlass {
    constructor($stateParams, $scope, $reactive) {
        'ngInject';

        $reactive(this).attach($scope);
        this.id = $stateParams.institution;
        this.anlass = Anlaesse.findOne({_id: $stateParams.anlass}) || 'not found: '+JSON.stringify($stateParams);
        this.helpers(
            {
                anlassHelper() {
                    return Anlaesse.findOne({_id: $stateParams.anlass});
                },
                /*name() {
                    return anl.name;
                }*/
            });
    }
}

export default angular.module(name, [
    angularMeteor,
    uiRouter,
]).component(name,{
    templateUrl: `imports/ui/components/anlaesse/${name}.html`,
    controllerAs: name,
    controller: Anlass
}).config(config);

function config($stateProvider){
    'ngInject';
    $stateProvider
        .state(name,{
            url: '/anlass/:anlass',
            template: '<anlass></anlass>'
        });
}