Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Not applicable

Cannot read property 'get' of undefined

Hi,

My project requires a newer version of angular. so my require-config looks as follows:

var config = {

    host: "localhost",

    prefix: "/",

    port: '443',

    isSecure: false

    };

    require.config( {

      baseUrl: ( config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port: "") + config.prefix,

      paths: {

           MyPaths

      },

      shim: {

           MyShims

          },

      priority: [

        'angular'

      ]

  });

  define( "client.services/grid-service", {} );

  require([

    'angular'

], function (angular) {

    require(['app'], function () {

        angular.bootstrap(document, ['MyApp']);

    });

});

However I am creating a seperate service provider to call the js/qlik:

define(['angular'], function (ng){

console.log(this)

var module = angular.module('qliksense.module', []);

  module.factory('Instance', function () {

    this.instance = null;

    return {

      get: function () {

        return this.instance;

      },

      set: function (value) {

        this.instance = value;

      }

    };

  });

   

  module.provider('Loader', function () {

    this.promise = null;

    this.config = {

      host: '',

        prefix: "/testing/",

      port: '',

      isSecure: false

    };

    this.appId = null;

    this.$get = function ($q, Instance) {

      var deferred = $q.defer();

      require.config({

        baseUrl: (this.config.isSecure ? "https://" : "http://") + this.config.host + (this.config.port ? ":" + this.config.port : "") + this.config.prefix + "resources"

      });

      require(['js/qlik'], function (qlik) {

        var app = qlik.openApp(this.appId, this.config);   

        Instance.set(app);

        deferred.resolve(app);

      });        

      return deferred.promise;

    };

  });

  module.config(function (LoaderProvider) {

    LoaderProvider.config = {

      host: 'MyUrl,

        prefix: "/testing/",

      port: '',

      isSecure: false

    };

    LoaderProvider.appId = '';

  });

return module

})

This works perfectly when in my require-config.js the baseUrl is set to the default path and calling my local js files with the full url path.

Also if I console.log the depencency require(['js/qlik'], function (qlik)  it brings me the qlik object correctly?

But the I get an error :: Cannot read property 'get' of undefined  - qlik.js line 17

All help is appreciated.

Tags (1)
2 Replies
erik_wetterberg
Valued Contributor III

Re: Cannot read property 'get' of undefined

Hi,

What qlik version are you using?? Have you tried this with the 2.2 version?

Erik

Erik Wetterberg
https://extendingqlik.upper88.com/
Not applicable

Re: Cannot read property 'get' of undefined

Hi, did you find a solution for this? Im getting the same one.