DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
    • can-construct-super
    • can-define-stream
    • can-fixture
    • can-fixture-socket
    • can-jquery
    • can-stache-converters
    • can-stream
    • can-vdom
    • can-view-import
      • Pages
        • Dynamic Imports
        • Static Imports
      • Attributes
        • can-tag
        • from
        • {^value}
    • can-zone
    • steal-stache
  • Infrastructure
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Ecosystem
  • /
  • can-view-import
  • /
  • can-tag
  • / On this page
    • can-tag

      function

      Use another tag (such as a can-component) to control the <content> of a can-view-import.

      • source

      can-tag="TAG_NAME"

      Instantiates the provided tag and sets its [can-component::viewModel viewModel] to be the Promise for the import.

      Parameters

      1. TAG_NAME {String}:

        The tag name (usually a can-component) to use.

      Use

      can-tag allows for injecting a component, using the imported promise as the injected component's view model.

      The example below shows a loading graphic until the cart component has been loaded. Once the cart promise is resolved, <shopping-cart></shopping-cart> is injected into the page.

      Loading Indicator Component

      var template = stache('{{#isResolved}}<content/>{{else}}<img src="loading.gif"/>{{/isResolved}}');
      
      Component.extend({
        tag: "loading-indicator",
        view: template
      });
      

      Main Template

      <can-import from="cart" can-tag="loading-indicator">
        <shopping-cart></shopping-cart>
      </can-import>
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.