我好像撞墙了,我无法分解.我正在使用angular + typescript,并希望使用requirejs.定义了多个角度应用程序,这些应用程序依赖于正文上的data-app-name属性进行加载.
文件夹结构(简化):
|- Libs
|- angular
|- some-plugin
|- angular-some-plugin // Exposes an angular.module("ngSomePlugin")
|- require.js
|- Common
|- Common.ts // Exposes an angular.module("common")
|- App1
|- Controllers
|- SomeController.ts
|- SomeOtherController.ts
|- Services
|- SomeService.ts
|- Main.ts
|- App.ts
|- App2
// same as above
|- AppX
// same as above
|- Index.html
|- Main.ts
Run Code Online (Sandbox Code Playgroud)
内容:
index.html的:
// All these attributes are set dynamically server-side
<body id="ng-app-wrapper" data-directory="App1" data-app-name="MyApp">
<script src="Libs/require.js" data-main="Main"></script>
</body>
Run Code Online (Sandbox Code Playgroud)
Main.ts:
console.log("Step 1: Main.js"); …Run Code Online (Sandbox Code Playgroud) 使用jQuery(或只是JavaScript),如何检测元素的继承背景颜色?
例如:
<div style="background-color: red">
<p id="target">I'd like to know that the background-color here is red</p>
</div>
Run Code Online (Sandbox Code Playgroud)
然而:
$('#target').css('background-color') == rgba(0,0,0,0)
Run Code Online (Sandbox Code Playgroud)
和
$('#target').css('backgroundColor') == rgba(0,0,0,0)
Run Code Online (Sandbox Code Playgroud)
我要求一般的解决方案. $('#target').parent().css('background-color')会在这种情况下工作,但不是全部.
刚刚开始演示Angular2项目(之前没有Angular1/AngularJS的经验.已经跟随并扩展了在线快速入门和教程,一切都很好.但是我想要使用库中的一些组件.是专为AngularJS设计的,并且没有任何问题!
关于AngularJS/Angular2兼容性的大部分可用信息假设您有一个AngularJS项目,您正在添加Angular2组件 - 而不是相反 - 所以我希望做的事情甚至可能无法实现.到目前为止我尝试过的是一个基于Angular2快速入门的简单剥离项目,其中一个Angular2组件加载到index.html中.然后,我想将现有库(基于AngularJS)的组件集成到此中.
我尝试使用UpgradeAdapter.upgradeNg1Component从库中创建组件并将它们直接添加到我的Angular2组件中
我试图通过NPM安装angularjs,在脚本标签到我导入它index.html,然后用的组合UpgradeAdapter.downgradeNg2Component和UpgradeAdapter.bootstrap加载我Angular2作为降级模块
这些似乎都不起作用 - 组件无法显示,浏览器控制台告诉我我已经有了 Uncaught SyntaxError: Unexpected token <
Evaluating http://localhost:3000/angular2/upgrade
Error loading http://localhost:3000/app/main.js
我最好的猜测是,这实际上是一个不受支持的场景,我需要一个"正确的"AngularJS应用程序才能使用UpgradeAdapterAngular2 的功能.谁能证实这一点?或者有什么愚蠢的我在这里失踪?
我以编程方式创建了PDF文件.为此,我使用了HTML到PDF转换库.在我的PDF中,有一些网站页面的链接.
我已按照以下方式实现了html,然后以编程方式将其转换为PDF.
<a target="_blank" href="http://mywebsite_url_here.html">Link</a>
Run Code Online (Sandbox Code Playgroud)
但是当打开这个PDF到chrome或firefox浏览器并点击PDF中存在的任何链接时.链接打开是相同的TAB而不是新的TAB.请帮助找出解决方案.这样我的PDF就会驻留在一个标签页中,链接将在浏览器的另一个标签页中打开.
我已经尝试过了
target="_blank"
target="_top"
<a onclick="window.open ('http://mywebsite_url_here.html', '');
return false" href="javascript:void(0);"></a>
Run Code Online (Sandbox Code Playgroud)
但没有什么对我有用.
我刚刚开始学习Angular.我ngModule在空的时候遇到了几个使用装饰器的例子class.
我想知道的是...... class直接在ngModule装饰器下面声明的是仅用于初始化模块还是用于任何其他目的?
我是Angular 4中的新手,并试图弄清楚一个简单项目的基本结构.我已经测试了我的项目,昨天工作得很好.但今天当我打开我的项目并想要"服务"时,它显示以下错误.不知道是什么问题.
TypeError: Cannot read property 'length' of undefined
at createSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:15457:109)
at parseSourceFileWorker (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:15389:26)
at Object.parseSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:15338:26)
at Object.createSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:15192:29)
at VirtualFileStats.getSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\@ngtools\webpack\src\compiler_host.js:66:35)
at WebpackCompilerHost.getSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\@ngtools\webpack\src\compiler_host.js:213:38)
at findSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67909:29)
at processImportedModules (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:68056:25)
at findSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67937:17)
at processSourceFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67840:27)
at processRootFile (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67728:13)
at C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67018:60
at Object.forEach (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:1449:30)
at Object.createProgram (C:\Users\IR\Desktop\angular-first-project\node_modules\typescript\lib\typescript.js:67018:16)
at AotPlugin._setupOptions (C:\Users\IR\Desktop\angular-first-project\node_modules\@ngtools\webpack\src\plugin.js:129:28)
at new AotPlugin (C:\Users\IR\Desktop\angular-first-project\node_modules\@ngtools\webpack\src\plugin.js:26:14)
Run Code Online (Sandbox Code Playgroud)
提前致谢.
我们如何计算开始和结束之间元素上滚动条所覆盖的"距离"百分比?
<div id="container" style="overflow-x:scroll; max-width:1000px;">
<div id="contained" style="width:3000px;"></div>
</div>
<script>
$('#container').scroll(function(){
var scrollPercentage; //How to get scroll percentage?
});
</script>
Run Code Online (Sandbox Code Playgroud)
所以,如果滚动条完全位于左侧,我们想要得到0,如果它完全在我们想要的右边100.
在下面的代码片段中,为什么在单击时会divClicked()触发两次<label>,但在单击时只触发一次<input>?
function divClicked(_index) {
console.log("div click event");
}
function inputClicked(_index) {
console.log("input click event");
}Run Code Online (Sandbox Code Playgroud)
<div class="option" onclick="divClicked(1)">
<input id="1_1" name="group_1" type="radio" value="1" onclick="inputClicked(1)" />
<label for="1_1">label</label>
</div>Run Code Online (Sandbox Code Playgroud)
注意:我想知道为什么会发生这种情况,而不是像"快速修复"那样:在标签上放置onclick().
我只是随机玩JavaScript.'2'+'2'-'2'我给它的输入.
并且输出令人惊讶20.
console.log('2'+'2'-'2');Run Code Online (Sandbox Code Playgroud)
现在我没有得到它.
有人向我解释为什么会这样?怎么输出这个等于20?
我在IntelliJ中熟悉它后,正在VS 2013中开展angular2 @ beta项目.IntelliJ可以设置为查找tsconfig.json文件,从TypeScript 1.6开始,它可以读取"exclude"属性,而不是尝试编译任何node_modules.现在我已经使用TypeScript 1.7迁移到VS 2013,我遇到了它正在尝试编译node_modules的问题.我已经包含了tsconfig.json,但是根据我的阅读,tsconfig.json仅在VS 2015中得到完全支持.这是最新的问题吗?有没有办法告诉VS 2013排除这些文件或使用我的tsconfig.json?
我还应该注意,当我进行npm安装时,angular2 @ beta包括其源代码的其余部分.这会将所有类型的内容与所有文件混合在一起,我想也许我可能必须删除所有非.d.ts文件以获得没有所有其他错误的输入.以前您可以使用"tsd install angular2"获取打字但这已不再可用.对此的解决方案将否定先前的问题.
更新
我可以在VS 2015 - 社区版上完成所有这些工作,但我真的很想知道我是否可以在VS 2013上使用它.
angular ×4
html ×4
javascript ×4
typescript ×3
jquery ×2
amd ×1
angularjs ×1
css ×1
math ×1
ng-modules ×1
pdf ×1
requirejs ×1
scroll ×1
string ×1
tsconfig ×1