本文整理汇总了TypeScript中angular2/core.enableProdMode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript enableProdMode函数的具体用法?TypeScript enableProdMode怎么用?TypeScript enableProdMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enableProdMode函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: enableProdMode
// Angular 2
import 'angular2/core';
import {enableProdMode} from 'angular2/core';
enableProdMode();
// For vendors for example jQuery, Lodash, angular2-jwt import them here
// Also see src/typings.d.ts as you also need to run `typings install x` where `x` is your module
开发者ID:IvanRave,项目名称:angular2example,代码行数:8,代码来源:vendor-ang.ts
示例2: function
module.exports = function(ROOT) {
var universalPath = `${ROOT}/dist/examples/app/universal`;
var appPage = require(`${universalPath}/test_page/app`);
var todoApp = require(`${universalPath}/todo/app`);
var routerApp = require(`${universalPath}/test_router/app`);
var {enableProdMode, provide} = require('angular2/core');
var {ROUTER_PROVIDERS, APP_BASE_HREF} = require('angular2/router');
enableProdMode();
var {
HTTP_PROVIDERS,
SERVER_LOCATION_PROVIDERS,
REQUEST_URL,
PRIME_CACHE,
queryParamsToBoolean
} = require('angular2-universal');
function static(path, route) {
// console.log(`${ROOT + route}`)
return {
method: 'GET',
path,
handler: {
directory: {
path: `${ROOT + route}`
}
}
};
}
function ngRouter(request, reply) {
let baseUrl = '/examples/router';
let url = request.originalUrl.replace(baseUrl, '') || '/';
let queryParams = queryParamsToBoolean(request.query);
let options = Object.assign(queryParams, {
// client url for systemjs
buildClientScripts: true,
componentUrl: 'examples/app/universal/test_router/browser',
// ensure that we test only server routes
client: false,
directives: [routerApp.App],
providers: [
// HTTP_PROVIDERS,
provide(APP_BASE_HREF, { useValue: baseUrl }),
provide(REQUEST_URL, { useValue: url }),
ROUTER_PROVIDERS,
SERVER_LOCATION_PROVIDERS,
],
data: {},
preboot: queryParams.preboot === false ? null : true
});
reply.view('app/universal/test_router/index', options);
}
function get(path, route) {
return {
method: 'GET',
path,
handler: route
};
}
var router: IHapiRoute[] = [{
method: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
path: '/{param*}',
handler: (request, reply) => {
reply({
'route': 'Sorry this page does not exist!'
});
}
}, {
method: 'GET',
path: '/',
handler: (request, reply) => {
let queryParams = queryParamsToBoolean(request.query);
let options = Object.assign(queryParams, {
// client url for systemjs
buildClientScripts: true,
componentUrl: 'examples/app/universal/test_page/browser',
directives: [appPage.App],
providers: [
// HTTP_PROVIDERS,
// SERVER_LOCATION_PROVIDERS,
// provide(BASE_URL, {useExisting: req.originalUrl}),
// provide(PRIME_CACHE, {useExisting: true})
],
data: {},
preboot: queryParams.preboot === false ? null : {
start: true,
//.........这里部分代码省略.........
开发者ID:Pishtiko,项目名称:universal,代码行数:101,代码来源:routes.ts
示例3: provide
import {provide, enableProdMode} from 'angular2/core';
import {bootstrap} from 'angular2/platform/browser';
import {ROUTER_PROVIDERS, APP_BASE_HREF} from 'angular2/router';
import {AppComponent} from './app/components/app.component';
import 'rxjs/Rx';
if ('<%= ENV %>' === 'prod') { enableProdMode(); }
bootstrap(AppComponent, [
ROUTER_PROVIDERS,
provide(APP_BASE_HREF, { useValue: '<%= APP_BASE %>' })
]);
window.addEventListener('dragover',function(e){
e.preventDefault();
},false);
window.addEventListener('drop',function(e){
e.preventDefault();
},false);
window.addEventListener('dragend',function(e){
e.preventDefault();
},false);
// In order to start the Service Worker located at "./sw.js"
// uncomment this line. More about Service Workers here
// https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers
// if ('serviceWorker' in navigator) {
// (<any>navigator).serviceWorker.register('./sw.js').then(function(registration) {
// console.log('ServiceWorker registration successful with scope: ', registration.scope);
// }).catch(function(err) {
// console.log('ServiceWorker registration failed: ', err);
开发者ID:Gerardo8,项目名称:lc-client,代码行数:31,代码来源:main.ts
示例4:
/*
* Providers provided by Angular
*/
import * as ngCore from 'angular2/core';
import * as browser from 'angular2/platform/browser';
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
import {HTTP_PROVIDERS} from 'angular2/http';
/*
* App Environment Providers
* providers that only live in certain environment
*/
const ENV_PROVIDERS = [];
if ('production' === process.env.ENV) {
ngCore.enableProdMode();
ENV_PROVIDERS.push(browser.ELEMENT_PROBE_PROVIDERS_PROD_MODE);
} else {
ENV_PROVIDERS.push(browser.ELEMENT_PROBE_PROVIDERS);
}
/*
* App Component
* our top level component that holds all of our components
*/
import {App} from './app/app';
/*
* Bootstrap our Angular app with a top level component `App` and inject
* our Services and Providers into Angular's dependency injection
*/
开发者ID:xgueret,项目名称:ng2-mean-webpack,代码行数:31,代码来源:main.ts
示例5: provide
import {provide, enableProdMode} from "angular2/core";
import {bootstrap} from "angular2/platform/browser";
// import {ROUTER_PROVIDERS, APP_BASE_HREF } from "angular2/router";
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from "angular2/router";
// import {AppComponent} from "./app/components/app.component";
import {AppCmp} from "./layout/base/components/app";
// // test to add external dependency
// import {Http, HTTP_PROVIDERS} from "angular2/http";
// import {AuthHttp, AuthConfig} from "angular2-jwt";
// dnd ot test
if ("<%= ENV %>" === "prod") { enableProdMode(); }
bootstrap(AppCmp, [
ROUTER_PROVIDERS,
provide(LocationStrategy, { useClass: HashLocationStrategy })
]);
/*
bootstrap(AppComponent, [
ROUTER_PROVIDERS, // remove HTTP_PROVIDERS, // add to test the addition of extenrnal dependency
provide(APP_BASE_HREF, { useValue: "<%= APP_BASE %>" }), // note APP_BASE is not correct
// provide(AuthHttp, { //add to test the addition of external dependency
// useFactory: (http: Http) => {
// return new AuthHttp(new AuthConfig(), http);
// },
// deps: [Http]
// }),
]);
*/
开发者ID:wuyingki,项目名称:angular2-seed,代码行数:31,代码来源:main.ts
示例6: function
module.exports = function(ROOT) {
var router = Router();
var appPage = require('../../universal/test_page/app');
var todoApp = require('../../universal/todo/app');
var routerApp = require('../../universal/test_router/app');
var {enableProdMode, provide} = require('angular2/core');
var {ROUTER_PROVIDERS, APP_BASE_HREF} = require('angular2/router');
enableProdMode();
var {
NODE_HTTP_PROVIDERS,
NODE_LOCATION_PROVIDERS,
NODE_PRELOAD_CACHE_HTTP_PROVIDERS,
REQUEST_URL,
PRIME_CACHE,
BASE_URL,
queryParamsToBoolean
} = require('angular2-universal-preview');
// require('angular2-universal')
router
.route('/')
.get(function ngApp(req, res) {
let queryParams = queryParamsToBoolean(req.query);
let options = Object.assign(queryParams, {
// client url for systemjs
buildClientScripts: true,
componentUrl: 'examples/src/universal/test_page/browser',
directives: [appPage.App, appPage.MyApp],
providers: [
NODE_LOCATION_PROVIDERS,
provide(REQUEST_URL, {useValue: req.originalUrl}),
provide(APP_BASE_HREF, {useValue: '/'}),
provide(BASE_URL, {useExisting: req.originalUrl}),
provide(PRIME_CACHE, {useExisting: true}),
// NODE_HTTP_PROVIDERS,
NODE_PRELOAD_CACHE_HTTP_PROVIDERS,
],
data: {},
precache: true,
preboot: queryParams.preboot === false ? null : {
start: true,
freeze: 'spinner', // show spinner w button click & freeze page
replay: 'rerender', // rerender replay strategy
buffer: true, // client app will write to hidden div until bootstrap complete
debug: false,
uglify: true,
presets: ['keyPress', 'buttonPress', 'focus']
}
});
res.render('src/universal/test_page/index', options);
});
router
.route('/examples/todo')
.get(function ngTodo(req, res) {
let queryParams = queryParamsToBoolean(req.query);
let options = Object.assign(queryParams , {
// client url for systemjs
buildClientScripts: true,
componentUrl: 'examples/src/universal/todo/browser',
directives: [todoApp.TodoApp],
providers: [
// NODE_HTTP_PROVIDERS,
// NODE_LOCATION_PROVIDERS,
// provide(BASE_URL, {useExisting: req.originalUrl}),
// provide(PRIME_CACHE, {useExisting: true})
],
data: {},
preboot: queryParams.preboot === false ? null : {debug: true, uglify: false}
});
res.render('src/universal/todo/index', options);
});
router
.route('/examples/falcor_todo')
.get(function ngTodo(req, res) {
let queryParams = queryParamsToBoolean(req.query);
let options = Object.assign(queryParams , {
// client url for systemjs
buildClientScripts: true,
componentUrl: 'examples/src/universal/falcor_todo/client',
directives: [todoApp.TodoApp],
//.........这里部分代码省略.........
开发者ID:bjwyse,项目名称:universal,代码行数:101,代码来源:routes.ts
注:本文中的angular2/core.enableProdMode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论