这就是我在fruit.ts中所拥有的
export type Fruit = "Orange" | "Apple" | "Banana"
Run Code Online (Sandbox Code Playgroud)
现在我在另一个打字稿文件中导入fruit.ts.这就是我所拥有的
myString:string = "Banana";
myFruit:Fruit = myString;
Run Code Online (Sandbox Code Playgroud)
当我做
myFruit = myString;
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
类型'字符串'不能分配给类型'"Orange"| "Apple"| "香蕉"'
如何将字符串分配给自定义类型Fruit的变量?
我有一个示例Spring Boot应用程序,其中包含以下内容
启动主类
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
Run Code Online (Sandbox Code Playgroud)
调节器
@RestController
@EnableAutoConfiguration
public class HelloWorld {
@RequestMapping("/")
String gethelloWorld() {
return "Hello World!";
}
}
Run Code Online (Sandbox Code Playgroud)
为控制器编写单元测试最简单的方法是什么?我尝试了以下但它抱怨无法自动装载WebApplicationContext
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = DemoApplication.class)
public class DemoApplicationTests {
final String BASE_URL = "http://localhost:8080/";
@Autowired
private WebApplicationContext wac;
private MockMvc mockMvc;
@Before
public void setup() {
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
}
@Test
public void testSayHelloWorld() throws Exception{
this.mockMvc.perform(get("/")
.accept(MediaType.parseMediaType("application/json;charset=UTF-8")))
.andExpect(status().isOk())
.andExpect(content().contentType("application/json"));
}
@Test
public void contextLoads() {
} …Run Code Online (Sandbox Code Playgroud) 我在Plunkr上有一个Angular 2 RC4基本表单示例,似乎抛出以下错误(在Chrome DEV控制台中)
这是傻瓜
https://plnkr.co/edit/GtPDxw?p=preview
错误:
browser_adapter.ts:82 EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error in ./App class App - inline template:1:7
ORIGINAL EXCEPTION: formGroup expects a FormGroup instance. Please pass one in.
Example: <form [formGroup]="myFormGroup">
ORIGINAL STACKTRACE:
Error: formGroup expects a FormGroup instance. Please pass one in.
Example: <form [formGroup]="myFormGroup">
at new BaseException (https://npmcdn.com/@angular/forms@0.2.0/src/facade/exceptions.js:27:23)
at FormGroupDirective._checkFormPresent (https://npmcdn.com/@angular/forms@0.2.0/src/directives/reactive_directives/form_group_directive.js:110:19)
at FormGroupDirective.ngOnChanges (https://npmcdn.com/@angular/forms@0.2.0/src/directives/reactive_directives/form_group_directive.js:39:14)
at DebugAppView._View_App0.detectChangesInter
Run Code Online (Sandbox Code Playgroud) 我在Spring MVC REST方面有很好的经验,并提供了几个可靠的项目.我的问题是关于JAX-RS合规性.这是否重要,因为Spring将继续存在,我无法预见(也没有理由)不得不在很短的时间内从Spring MVC REST转移到Jersy或任何其他JAX-RS.任何应该迫使我考虑使用JAX-RS实现而不是Spring MVC REST的东西?
这是我的对象(它有n个动态键.我在下面的例子中只显示了两个)
let obj = {
abc:["some text", "some more text"],
xyz:["more text", "what do you think?", "I'm tired now"]
}
Run Code Online (Sandbox Code Playgroud)
这是我尝试循环抛出上面的内容并打印所有值
<div *ngFor='let item of obj ; let i = index;'>
<p *ngFor="let value of obj.i">{{value}}
</div>
Run Code Online (Sandbox Code Playgroud)
但上述似乎不起作用.我做错了什么,语法是正确的?
我正在从Angular 2 RC4升级到RC5
这是我目前的主要内容
import {enableProdMode} from '@angular/core';
import {bootstrap} from '@angular/platform-browser-dynamic';
import {AppComponent} from './app/app.component';
import {AppRoutes} from './app/app.routes';
import { provideRouter } from '@angular/router';
import { XHRBackend } from '@angular/http';
import { HTTP_PROVIDERS } from '@angular/http';
import { LocationStrategy,
HashLocationStrategy } from '@angular/common';
import {disableDeprecatedForms, provideForms} from '@angular/forms';
import {provide} from '@angular/core';
enableProdMode();
bootstrap(AppComponent, [
disableDeprecatedForms(),
provideForms(),
provideRouter(AppRoutes)
,HTTP_PROVIDERS,
provide(LocationStrategy, {useClass: HashLocationStrategy})
])
.catch(err => console.error(err));
Run Code Online (Sandbox Code Playgroud)
这是我更新的main.ts
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import {AppModule} from './app/app.module';
platformBrowserDynamic().bootstrapModule(AppModule); …Run Code Online (Sandbox Code Playgroud) Angular2具有动态生成表单的能力(模型驱动表单),而不是手动生成表单(模板驱动).
我有动态表单的变体,其中整个表单生成功能作为模块公开(Angular RC5).
但它打破了以下错误(出现在开发控制台中)
VM849:20 Error: Error: Unexpected value 'undefined' exported by the module 'DynamicFormModule'
Run Code Online (Sandbox Code Playgroud)
这是傻瓜
我正在HTML中的自由键入的输入文本字段上执行某种形式的验证.有没有办法使用JQuery或JavaScript在输入文本字段中突出显示某些单词或短语(基于某些标准)?
我有以下html表单select语句
<select ng-change="setBillGroup()" ng-model="bill.groupId" class="span8" ng-options="d.id as d.name for d in groups"></select>
Run Code Online (Sandbox Code Playgroud)
和js
myApp.controller('myAppController', function($scope, myAppService) {
.....
function setBillGroup(){
console.log("setBillGroup method called!");
......
}
....
});
Run Code Online (Sandbox Code Playgroud)
但由于某种原因,当我在表单中选择某个或另一个时,似乎永远不会调用setBillGroup().
我初始化了一个git存储库,用于添加Oracle Weblogic服务器的本地实例(是!),以便使用git对其进行版本化.
oracle文件位于c:\ Oracle中.所以我需要将相同的内容添加到git中
我发出了以下命令
git init(在c:\中有Oracle目录)
在c:\中添加了一个.gitignore目录,并忽略了c:\中除Oracle之外的所有目录
然后运行'git status'来查看状态.正如所料,它显示了以下内容
C:\>git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
# Oracle/
nothing added to commit but untracked files present (use "git add" to track)
Run Code Online (Sandbox Code Playgroud)
现在,我做了一个git add*上面的命令按预期抛出了一些详细的输出,显示了正在添加的文件并以下面结束(命令输出的尾部显示在下面)
....
base_domain/servers/AdminServer/tmp/.appmergegen_1387484701373_liferay-portal-6.
1.30-ee-ga3-20130812170130063.war/html/VAADIN/themes/runo/tree/tree.css.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in Oracle/Middleware/user_projects/domains/ …Run Code Online (Sandbox Code Playgroud) angular ×5
javascript ×4
html ×2
java ×2
typescript ×2
angularjs ×1
git ×1
iteration ×1
jax-rs ×1
jquery ×1
junit ×1
loops ×1
module ×1
ngfor ×1
rest ×1
select ×1
spring ×1
spring-boot ×1
spring-mvc ×1
unit-testing ×1
validation ×1