我正在学习Angular 2中的属性指令。在属性指令中使用BOOT_COMPLETED
别名时,它不起作用,为什么?
@Input
<p appHighlight = "color">Hightlight Me</p>
答案 0 :(得分:3)
符号应该是这样的:
<p myHighlight [appHighlight]="color">Hightlight Me</p>
带括号
假设选择器是:
@Directive({
selector: '[myHighlight]'
})
export class HighlightDirective {
constructor(private el: ElementRef) { }
@Input('appHighlight') highlightcolor: string;
...
Plunker示例:http://plnkr.co/edit/vqZ4gjHc1KNFro62HlVJ?p=preview
答案 1 :(得分:1)
来自angular docs -
/**
* Definition for singly-linked list.
* class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
*/
public class Solution {
public boolean hasCycle(ListNode head) {
if(head == null){
return false;
}
ListNode slow = head;
ListNode fast = head.next;
while((slow != null) && (fast != null) && (slow.next != null) && (fast.next != null)){
if(slow == fast){
return true;
}
slow = slow.next;
fast = fast.next.next;
}
return false;
}
}