To reference an application-level module in a widget, you must list the module as a dependency using the ccResourceLoader library. For example, the following code creates a dependency on the demo.shared.viewmodels module:

define(
  //-------------------------------------------------------------------
  // DEPENDENCIES
  //-------------------------------------------------------------------
  ['jquery', 'knockout', 'ccLogger',
    'ccResourceLoader!global/demo.shared.viewmodels'],
  //-------------------------------------------------------------------
  // Module definition
  //-------------------------------------------------------------------
  function ($, ko, ccLogger, sharedViewModel) {
    'use strict';
    return {
      onLoad : function(widget) {
        widget.firstName = sharedViewModel.viewModel().firstName;
        widget.surname = sharedViewModel.viewModel().surname;
        widget.doMessage = sharedViewModel.doMessage;
      }
    };
  }
);

Copyright © 1997, 2016 Oracle and/or its affiliates. All rights reserved. Legal Notices