當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript knockout.components類代碼示例

本文整理匯總了TypeScript中knockout.components的典型用法代碼示例。如果您正苦於以下問題:TypeScript components類的具體用法?TypeScript components怎麽用?TypeScript components使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了components類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: registerDropdown

export function registerDropdown(): boolean {
  if (!ko.bindingHandlers.msoptions)
    addMsDropdownBindingHandler();

  if (!ko.components.isRegistered(DROPDOWN_COMPONENT)) {
    ko.components.register(DROPDOWN_COMPONENT, {
      template: DropdownView.templateHtml,
      viewModel: DropdownViewModel
    });
  }

  return true;
}
開發者ID:,項目名稱:,代碼行數:13,代碼來源:

示例2: return

    return (target: { new (...args) }) => {
        if (!ko.components.isRegistered(options.selector)) {
            if (!options.template && !options.templateUrl) {
                throw Error(`Component ${target.name} must have template`);
            }

            const factory = getFactory(target);
            const config = {
                template: options.template || { require: options.templateUrl },
                viewModel: factory
            };

            ko.components.register(options.selector, config);
        }
    };
開發者ID:Veikedo,項目名稱:di-decorator,代碼行數:15,代碼來源:Component.ts

示例3: registerHomePageViewModel

export function registerHomePageViewModel() {
    ko.components.register('home-page',{
        viewModel: {
            createViewModel: (params,componentInformation) : IHomePageViewModel => {
                var viewModel = kernel.get<IHomePageViewModel>("IHomePageViewModel");
                viewModel.init(params);
                return viewModel;
            }
        },
        template: componentTemplate
    });
}
開發者ID:darcy-buttrose,項目名稱:ko-ts-inversify-131,代碼行數:12,代碼來源:register.ts

示例4: registerComponent

 public registerComponent(name: string, location: string)
 {
   ko.components.register(name, { require: location });
 }
開發者ID:piofthings,項目名稱:whereami,代碼行數:4,代碼來源:config.ts

示例5: initApplication

/// <reference path="../typings/browser.d.ts" />
import * as ko from 'knockout';
import { BuildingViewModel, buildingTemplate } from './components/building';
import { CivViewModel, civTemplate } from './components/civilization';
import * as game from './services/game';

ko.components.register('building', { viewModel: BuildingViewModel, template: buildingTemplate });
ko.components.register('civilization', { viewModel: CivViewModel, template: civTemplate });

if (document.readyState === "loading") {
    document.onreadystatechange = () => { if (document.readyState === "interactive") initApplication(); }
}
else{
    initApplication();
}

function initApplication(){
    const myCiv = new game.Civilisation();
    ko.applyBindings({ civ: myCiv });
}

開發者ID:Sidoine,項目名稱:FormationTypeScript,代碼行數:20,代碼來源:main.ts

示例6: require

// const log = log4js.getLogger("app.main");
const log = {
	trace: console.log,
	fatal: console.log
};

import * as ko from "knockout";
import { sleep } from "@zxnode/base";

import AppViewModel from "./ViewModels/AppViewModel";

// Register widgets
log.trace("Registering Knockout widget: app-view");
ko.components.register("app-view", {
	template: require("./Views/AppView.html")
});

// Initializing and start
log.trace("Creating application view model");
const appVM = new AppViewModel();
log.trace("Initializing application view model");
Promise.all([
	appVM.init(),
	sleep(1)
]).then(() => {
	log.trace("Activates knockout.js");
	ko.applyBindings(appVM);
}).catch((reason) => {
	log.fatal("Crash", reason);
	alert("Crash");
開發者ID:theanurin,項目名稱:tagfs,代碼行數:30,代碼來源:app.main.ts

示例7: remove

  function remove() {
    widgets.remove(this);
  }

  return {
    widgets,
    addCalculator,
    addToDoList,
    addWeather,
    addTranslate,
    remove
  };
}

ko.components.register('calculator', {
  viewModel: { require: 'lib/calculator' },
  template: { require: 'text!lib/calculator.html' }
});

ko.components.register('todo-list', {
  viewModel: { require: 'lib/todo-list' },
  template: { require: 'text!lib/todo-list.html' }
});

ko.components.register('weather', {
  viewModel: { require: 'lib/weather' },
  template: { require: 'text!lib/weather.html' }
});

ko.components.register('translate', {
  viewModel: { require: 'lib/translate' },
  template: { require: 'text!lib/translate.html' }
開發者ID:SMH110,項目名稱:widgets,代碼行數:32,代碼來源:app.ts

示例8:

/// <reference path="./../references.d.ts" />

import * as ko from "knockout";
import * as $ from "jquery";
import * as bootstrap from "bootstrap";
import * as router from "./router";

// Components can be packaged as AMD modules, such as the following:
ko.components.register('nav-bar', { require: 'components/nav-bar/nav-bar' });
ko.components.register('home-page', { require: 'components/home-page/home' });

// ... or for template-only components, you can just point to a .html file directly:
ko.components.register('about-page', {
  template: { require: 'text!components/about-page/about.html' }
});

// [Scaffolded component registrations will be inserted here. To retain this feature, don't remove this comment.]

// Start the application
ko.applyBindings({ route: router.currentRoute });
開發者ID:chiyiangel,項目名稱:generator-ko-ts,代碼行數:20,代碼來源:startup.ts

示例9: createBrowserHistory

import './css/site.css';
import 'bootstrap';
import * as ko from 'knockout';
import { createBrowserHistory } from 'history';
import './webpack-component-loader';
import AppRootComponent from './components/app-root/app-root';
const baseUrl = document.getElementsByTagName('base')[0].getAttribute('href')!;
const basename = baseUrl.substring(0, baseUrl.length - 1); // History component needs no trailing slash

// Load and register the <app-root> component
ko.components.register('app-root', AppRootComponent);

// Tell Knockout to start up an instance of your application
ko.applyBindings({ history: createBrowserHistory({ basename }), basename });

// Basic hot reloading support. Automatically reloads and restarts the Knockout app each time
// you modify source files. This will not preserve any application state other than the URL.
if (module.hot) {
    module.hot.accept();
    module.hot.dispose(() => ko.cleanNode(document.body));
}
開發者ID:juniwang,項目名稱:rasg,代碼行數:21,代碼來源:boot.ts

示例10:

// Validation
ko.validation.init({
	grouping : { deep: true, observable: true }, 
	decorateInputElement: true, 
	parseInputAttributes: true, 
	decorateElementOnModified: false, 
	messagesOnModified: false,
	errorElementClass: 'has-error',
    errorMessageClass: 'help-block'},
	true);

/* Pages */
ko.components.register('home-page', {
	template: {
		require: 'components/home-page/home.html!text'
	},
	viewModel: {
		require: 'components/home-page/home'
	}
});

ko.components.register('about-page', {
	template: {
		require: 'components/about-page/about.html!text'
	},
	viewModel: {
		require: 'components/about-page/about'
	}
});

ko.components.register('contact-page', {
	template: {
開發者ID:robertsundstrom,項目名稱:express-knockout-spa,代碼行數:32,代碼來源:startup.ts


注:本文中的knockout.components類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。