当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript camelcase类代码示例

本文整理汇总了TypeScript中camelcase的典型用法代码示例。如果您正苦于以下问题:TypeScript camelcase类的具体用法?TypeScript camelcase怎么用?TypeScript camelcase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了camelcase类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

 constructor(info?: ResourceDefinition, routes?: Routes) {
   if (info && info.routes) {
     if (routes) {
       throw new Error('double routes specification');
     }
     routes = info.routes;
     delete info.routes;
   }
   Object.assign(this, info);
   if (!this.name) {
     this.name = Resource.capitalize(camelcase(this.constructor.name));
   }
   if (!this.namePlural) {
     this.namePlural = this.name + 's';
   }
   this[__operations] = [];
   if (routes) {
     for (let path in routes) {
       let handlers = routes[path];
       for (let method in handlers) {
         this.addOperation(path, method as  Method, handlers[method]);
       }
     }
   }
 }
开发者ID:vivocha,项目名称:arrest,代码行数:25,代码来源:resource.ts

示例2: transfromPropertyName

  static transfromPropertyName(propertyName: string) {
    let tsPropertyName = camelcase(propertyName);

    if (propertyName.startsWith('_')) {
      tsPropertyName = `_${tsPropertyName}`;
    }

    return tsPropertyName;
  }
开发者ID:vintage-software,项目名称:vstack-typescript-generator,代码行数:9,代码来源:utility.ts

示例3: toInjectorName

export function toInjectorName(token) {
	if (typeof token === 'string') {
		return token;
	}

	if (token instanceof OpaqueToken) {
		return camelcase(token.toString());
	}

	return token.name;
}
开发者ID:thihara,项目名称:angular2-seed,代码行数:11,代码来源:utils.ts

示例4: while

	properties.forEach(property => {
		const splitted = property.split('.');

		if (splitted.length === 1) {
			// Set the property directly
			el.prop(camelcase(property), value);
		} else {
			const root = splitted.shift();

			if (root === 'class') {
				// Handle adding/removing class names
				const method = value ? 'addClass' : 'removeClass';
				el[method](splitted.join('.'));
			} else {
				// Handle deeply nested properties
				let runner = el.prop(camelcase(root));
				while (splitted.length > 1) {
					runner = runner[camelcase(splitted.shift())];
				}
				runner[camelcase(splitted.shift())] = value;
			}
		}
	});
开发者ID:thihara,项目名称:angular2-seed,代码行数:23,代码来源:utils.ts

示例5: bootstrap

export function bootstrap(ngModule, target, parentState?: string) {
	const annotations = target.__annotations__;
	const component = annotations.component;
	const name = camelcase(component.selector);
	const styleElements: any[] = [];
	const headEl = angular.element(document).find('head');

	if (map[target.name]) {
		return name;
	}

	map[target.name] = component.selector;

	// Bootstrap providers, directives and pipes
	(component.providers || []).forEach(provider => bootstrapHelper(ngModule, provider));
	(component.directives || []).forEach(directive => bootstrapHelper(ngModule, directive));
	(component.pipes || []).forEach(pipe => bootstrapHelper(ngModule, pipe));

	// Define the style elements
	(component.styles || []).forEach(style => {
		styleElements.push(angular.element('<style type="text/css">@charset "UTF-8";' + style + '</style>'));
	});
	(component.styleUrls || []).forEach(url => {
		styleElements.push(angular.element('<link rel="stylesheet" href="' + url + '">'));
	});

	// Inject the services
	inject(target);

	ngModule
		.controller(target.name, target)
		.directive(name, ['$compile', ($compile) => {
			const directive: any = {
				restrict: 'E',
				scope: {},
				bindToController: {},
				controller: target.name,
				controllerAs: component.exportAs || name,
				compile: () => {
					return {
						pre: (scope, el) => {
							if (target.prototype.ngOnInit) {
								const init = $compile(`<div ng-init="${name}.ngOnInit();"></div>`)(scope);
								el.append(init);
							}

							// Prepend all the style elements
							styleElements.forEach(el => headEl.prepend(el));

							// Remove all the style elements when destroying the directive
							scope.$on('$destroy', () => {
								styleElements.forEach(el => el.remove());
							});
						}
					}
				}
			};

			(component.inputs || []).forEach(input => directive.bindToController[input] = '=');

			Object.keys(annotations.inputs || {}).forEach(key => directive.bindToController[key] = '=' + annotations.inputs[key]);

			if (component.template) {
				directive.template = component.template;
			} else {
				directive.templateUrl = component.templateUrl;
			}

			return directive;
		}]);

	if (annotations.routes) {
		var cmpStates = [];

		annotations.routes.forEach(route => {
			const name = route.name || route.as;

			if (route.component.name !== component.name) {
				bootstrap(ngModule, route.component, name);
			}

			cmpStates.push(name);
			states[name] = {
				url: route.path,
				controller: route.component.name,
				template: `<${map[route.component.name]}></${map[route.component.name]}>`,
				isDefault: route.useAsDefault === true
			};

			if (parentState) {
				states[name].parent = parentState;
			}
		});

		ngModule.config(['$urlRouterProvider', '$stateProvider', ($urlRouterProvider, $stateProvider) => {
			cmpStates.forEach(name => {
				const state = states[name];
				$stateProvider.state(name, state);

				if (state.isDefault) {
//.........这里部分代码省略.........
开发者ID:klaascuvelier,项目名称:angular2-polyfill,代码行数:101,代码来源:component.ts

示例6: bootstrap

export function bootstrap(ngModule, target, parentState?: any) {
	const annotations = target.__annotations__;
	const component = annotations.component;
	const name = camelcase(component.selector || target.name);
	const styleElements: any[] = [];
	const headEl = angular.element(document).find('head');

	if (map[target.name]) {
		return name;
	}

	map[target.name] = decamelize(component.selector || target.name, '-');

	// Bootstrap providers, directives and pipes
	(component.providers || []).forEach(provider => utils.bootstrapHelper(ngModule, provider));
	(component.directives || []).forEach(directive => utils.bootstrapHelper(ngModule, directive));
	(component.pipes || []).forEach(pipe => utils.bootstrapHelper(ngModule, pipe));

	// Define the style elements
	(component.styles || []).forEach(style => {
		styleElements.push(angular.element('<style type="text/css">@charset "UTF-8";' + style + '</style>'));
	});
	(component.styleUrls || []).forEach(url => {
		styleElements.push(angular.element('<link rel="stylesheet" href="' + url + '">'));
	});

	// Inject the services
	utils.inject(target);

	const hostBindings = utils.parseHosts(component.host || {});

	ngModule
		.controller(target.name, target)
		.directive(name, ['$compile', ($compile) => {
			const directive: any = {
				restrict: 'E',
				scope: {},
				bindToController: {},
				controller: target.name,
				controllerAs: component.exportAs || '$ctrl',
				transclude: true,
				compile: () => {
					// Prepend all the style elements to the `head` dom element
					styleElements.forEach(el => headEl.prepend(el));

					return {
						pre: (scope, el) => {
							// Bind the hosts
							utils.bindHostBindings(scope, el, hostBindings, component.exportAs || name);

							if (target.prototype.ngOnInit) {
								// Call the `ngOnInit` lifecycle hook
								const init = $compile(`<div ng-init="${directive.controllerAs}.ngOnInit();"></div>`)(scope);
								el.append(init);
							}

							scope.$on('$destroy', () => {
								// Remove all the style elements when destroying the directive
								styleElements.forEach(el => el.remove());

								if (target.prototype.ngOnDestroy) {
									// Call the `ngOnDestroy` lifecycle hook
									scope[directive.controllerAs].ngOnDestroy();
								}
							});
						}
					}
				}
			};

			// Bind inputs and outputs
			utils.bindInput(target, directive);
			utils.bindOutput(target, directive);

			// Set the template
			if (component.template) {
				directive.template = component.template;
			} else {
				directive.templateUrl = component.templateUrl;
			}

			return directive;
		}]);

	if (annotations.routes) {
		var cmpStates = [];

		annotations.routes.forEach(route => {
			const name = route.name || route.as;
			const routerAnnotations = route.component.__annotations__ && route.component.__annotations__.router;

			const state: any = {
				name,
				url: route.path,
				isDefault: route.useAsDefault === true
			}

			// Bootstrap the route component if it's not the same as the target component
			if (route.component.name !== component.name) {
				bootstrap(ngModule, route.component, state);
//.........这里部分代码省略.........
开发者ID:Ledragon,项目名称:angular2-polyfill,代码行数:101,代码来源:component.ts

示例7: camelCase

 let formatter = (token) => program['camelCase'] ? camelCase(token) : token;
开发者ID:Bolisov,项目名称:sass-css-modules-to-typings-converter,代码行数:1,代码来源:index.ts


注:本文中的camelcase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。