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


TypeScript camelcase.default方法代碼示例

本文整理匯總了TypeScript中camelcase.default方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript camelcase.default方法的具體用法?TypeScript camelcase.default怎麽用?TypeScript camelcase.default使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在camelcase的用法示例。


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

示例1: Error

 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:

	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.default方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。