• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript knockout.components类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript knockout.mapping类代码示例发布时间:2022-05-25
下一篇:
TypeScript knockout.bindingHandlers.css类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap