本文整理汇总了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]);
}
}
}
}
示例2: transfromPropertyName
static transfromPropertyName(propertyName: string) {
let tsPropertyName = camelcase(propertyName);
if (propertyName.startsWith('_')) {
tsPropertyName = `_${tsPropertyName}`;
}
return tsPropertyName;
}
示例3: toInjectorName
export function toInjectorName(token) {
if (typeof token === 'string') {
return token;
}
if (token instanceof OpaqueToken) {
return camelcase(token.toString());
}
return token.name;
}
示例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;
}
}
});
示例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) {
//.........这里部分代码省略.........
示例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);
//.........这里部分代码省略.........
示例7: camelCase
let formatter = (token) => program['camelCase'] ? camelCase(token) : token;