Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. var myComponentLoader = {
  2. loadComponent: function(name, componentConfig, callback) {
  3. System.import(componentConfig.myLoader)
  4. .then(function(loadedComponent) {
  5.  
  6. var result = {
  7. template: ko.utils.parseHtmlFragment(loadedComponent.componentTemplate),
  8. createViewModel: loadedComponent.MyComponentViewModel
  9. }
  10. callback(result);
  11. })
  12. // .catch(function(myError){
  13. // alert(myError);
  14. // callback(null);
  15. // });
  16. }
  17. };
  18.  
  19. // Register it
  20. ko.components.loaders.unshift(myComponentLoader);
  21.  
  22. ko.components.register('my-component', { myLoader: './app/components/components' });
  23.  
  24. <div>This is my component template</div>
  25. <div data-bind="text: myName"></div>
  26.  
  27. function MyComponentViewModel(params) {
  28. // Set up properties, etc.
  29. this.myName = ko.observable("Amy Smith");
  30. this.doSomething(params);
  31. this.boundAt = ko.observable(moment().format());
  32. }
  33.  
  34. Potentially unhandled rejection [1] TypeError: undefined is not a function
  35. at Object.ko.utils.cloneNodes (http://localhost:8081/lib/bower/knockout@3.3.0/dist/knockout.js:270:48)
  36. at cloneTemplateIntoElement (http://localhost:8081/lib/bower/knockout@3.3.0/dist/knockout.js:3644:41)
  37. at null.callback (http://localhost:8081/lib/bower/knockout@3.3.0/dist/knockout.js:3621:21)
  38. at Function.ko_subscribable_fn.notifySubscribers (http://localhost:8081/lib/bower/knockout@3.3.0/dist/knockout.js:1103:38)
  39. at http://localhost:8081/lib/bower/knockout@3.3.0/dist/knockout.js:3151:54
  40. at http://localhost:8081/lib/bower/knockout@3.3.0/dist/knockout.js:3169:21
  41. at http://localhost:8081/lib/bower/knockout@3.3.0/dist/knockout.js:3198:29
  42. at eval (http://localhost:8081/app/components/components-bootstrapper.js!eval:32:13)
  43. at O (http://localhost:8081/lib/es6-module-loader.js:7:7439)
  44. at K (http://localhost:8081/lib/es6-module-loader.js:7:7071)
  45.  
  46. template: ko.utils.parseHtmlFragment(loadedComponent.componentTemplate)
  47.  
  48. createViewModel: function (params, componentInfo) { return new loadedComponent.viewModel(params, componentInfo); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement