AngularJS有&参数,你可以将回调传递给指令(例如AngularJS的回调方式.是否可以将回调作为@InputAngular组件传递(如下所示)?如果不是,最接近什么是什么? AngularJS呢?
@Component({
selector: 'suggestion-menu',
providers: [SuggestService],
template: `
<div (mousedown)="suggestionWasClicked(suggestion)">
</div>`,
changeDetection: ChangeDetectionStrategy.Default
})
export class SuggestionMenuComponent {
@Input() callback: Function;
suggestionWasClicked(clickedEntry: SomeModel): void {
this.callback(clickedEntry, this.query);
}
}
<suggestion-menu callback="insertSuggestion">
</suggestion-menu>
Run Code Online (Sandbox Code Playgroud) 我知道有.set()方法将布尔值设置为true或false但我想知道是否有类似.set()的方法,除非它切换布尔值.
在这种情况下,布尔值isEditing被设置为"true".
isEditing:false,
actions: {
edit: function(category){
category.set('isEditing', true);
console.log(this.get('isEditing'))
},
}
Run Code Online (Sandbox Code Playgroud)
这是html
{{#if isEditing}}
<div class="category-text">
{{view Ember.TextField valueBinding=name action="turnOffEditMode"}}
</div>
{{else}}
<div class="category-text">
{{#linkTo 'category' this}}
{{name}}
{{/linkTo}}
</div>
{{/if}}
Run Code Online (Sandbox Code Playgroud) 首先,这不是以下内容的克隆:iPad/iPhone 悬停问题导致用户双击链接, 因为我想要一个纯 CSS 的答案。此链接中的所有答案都需要 js 或 jQuery,而一个 CSS 答案涉及背景图像。我正在尝试更改不透明度,仅此而已。
CSS 想要将自己推向移动革命,但我看到的用于创建悬停效果的简单“touchDown”(又名触摸悬停)的每个解决方案都需要 javascript 或 jQuery。
下面是一些简单的代码来说明我的意思:
.btn {
border-radius: 5px;
display: block;
opacity: 1; <--from
background: red;
text-align: center;
line-height: 40px;
font-weight: bold;
&:hover {
opacity:.7; <--to
transition: opacity .2s ease-out; <--fun fade animation :)
-moz-transition: opacity .2s ease-out;
-webkit-transition: opacity .2s ease-out;
-o-transition: opacity .2s ease-out;
}
}
Run Code Online (Sandbox Code Playgroud)
在 Chrome 和 Safari 中测试
为什么在使用 Protractor API 函数时会收到错误消息?我在互联网上搜索了这个问题的解决方案,我找到了几个类似的答案,但它们没有用,所以我问社区。
我正在尝试使用 Karma 和 Protractor 设置最简单的 e2e 测试。像这样的空测试代码块不会产生错误:
describe('Mapping Assistant State', () => {
beforeEach(() => {
});
it('should display a table',() => {
console.log('test');
});
it('should click the create Paste button',() => {
});
});
Run Code Online (Sandbox Code Playgroud)
一旦我从量角器中添加了某些函数,如expect() 或browser(),就会出现问题:
it('should display a table',() => {
browser.get('someUrl');
expect(element(by.css('.map')).getText()).toContain('map');
});
Run Code Online (Sandbox Code Playgroud)
以下是我的 package.json 的一些内容:
"protractor": "^5.3.0",
"karma": "^1.7.1",
"@angular/cli": "^1.6.6",
"typescript": "^2.5.2"
"@angular/core": "^4.3.6",
"rxjs": "^5.4.3",
"@types/selenium-webdriver": "^3.0.6",
"ts-node": "^4.0.1",
"@types/node": "^8.0.58",
Run Code Online (Sandbox Code Playgroud)
还:
import { browser, by, element } from 'protractor'; …Run Code Online (Sandbox Code Playgroud) 我想检测我是否正在滚动,但仅在我从当前位置滚动一定距离后才检测。当我停止滚动时,此距离重置为当前位置
我知道如何使用 检测滚动经过页面上的某个点.scrollTop(),但我希望这个特定点成为我当前的位置,但只有在我停止滚动之后。
为什么我需要这个:我有一个导航栏,它可以根据我是否向上或向下滚动来更改所有CSS。因此,如果我的滚动手指向不同方向颤抖(例如从上到下滚动),导航栏将像闪光灯一样变换。所以我的计划是仅检测高于或低于 10px 的滚动,因此用户需要制作专用滚动来激活导航栏 css 更改。
伪代码:
if (scrolled 10px above or below current_location in browser) {
console.log('it worked');
} else {
console.log('You have not scrolled far enough!')
}
if (scrolling stops) {
reset position of current_location.
}
Run Code Online (Sandbox Code Playgroud) 我希望我的浏览器选项卡知道它何时被复制。
我见过的唯一类似的解决方案只关注知道它已被重复的重复选项卡或知道它已被重复的原始选项卡,但这仅适用于 Chrome。
要求:
奖金如果解决方案:
当我尝试查看用户索引时,我一直遇到错误.这是Hartl的Ruby on Rails教程(一个优秀的教程)的第9章
错误的参数数量(2为1)
<li>
<%= gravatar_for user, size: 52 %>
<%= link_to user.name, user %>
<% if current_user.admin? && !current_user?(user) %>
| <%= link_to "delete", user, method: :delete,
data: { confirm: "You sure?" } %>
<% end %>
</li>
Run Code Online (Sandbox Code Playgroud)
我不知道为什么它认为第2行认为我在调用2个参数.
我正在尝试将此过滤搜索栏的工作示例http://jsbin.com/AViZATE/37/edit与我自己的项目合并.搜索栏似乎没有连接到我的对象列表.:(
让我告诉你我做了什么.
App.RecordCategoriesController = Ember.ArrayController.extend({
searchResult: function(){
var searchTerm = this.get('searchTerm');
var regExp = new RegExp(searchTerm,'i');
this.get('model').set('content',this.store.filter('recordCategory',function(item){
return regExp.test(item.get('categoryName'));
}));
}.observes('searchTerm'),
});
Run Code Online (Sandbox Code Playgroud)
正如您在上面所看到的,我已将' todo'与' recordCategory'和' title'替换为' categoryName'.到目前为止似乎很好.'
在record_categories.hbs中,我创建了将用于过滤的输入栏.
{{input type="text" id="search-todo" placeholder="Search Todo List..." value=searchTerm}}
Run Code Online (Sandbox Code Playgroud)
然后在它下面,#each把手循环并显示我的列表
{{#each itemController="recordCategory"}}
<li>{{categoryName}}</li>
{{/each}}
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?我注意到searchResults似乎没有在他们的示例中的任何其他地方调用
这也是我的路线,因为为什么不.
App.RecordCategoriesRoute = Ember.Route.extend({
model: function() {
VpcYeoman.RecordCategories.FIXTURES=[];
$.ajax({
url: '/recordCategories',
dataType: 'json',
type:"get",
async: false,
success : function(data, textStatus, xhr) {
if(xhr.status==200){
VpcYeoman.RecordCategories.FIXTURES=data;
}
}
});
return this.store.find('recordCategories');
}
});
Run Code Online (Sandbox Code Playgroud) javascript model-view-controller filtering handlebars.js ember.js
我想做一些类似的事情nth-last-child(1 + odd),最后一个孩子受到影响,但只有元素是奇数.
nth-last-child(1 + odd) 虽然不起作用,所以我该怎么办?
奖金:一个更灵活的答案,允许我抓住最后一个孩子,只有它是奇怪的和奇怪的孩子在它之前.
<ul>
<li>not effected</li>
<li>not effected</li>
<li>not effected</li>
<li>not effected</li>
<li>affected</li>
<li>not effected</li>
<li>affected</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
但如果最后一个孩子即将到来,则没有任何反应,所以:
<ul>
<li>not effected</li>
<li>not effected</li>
<li>not effected</li>
<li>not effected</li>
<li>not effected</li>
<li>not effected</li>
</ul>
Run Code Online (Sandbox Code Playgroud) javascript ×4
angular ×3
css ×3
ember.js ×2
typescript ×2
angularjs ×1
boolean ×1
browser-tab ×1
css3 ×1
duplicates ×1
e2e-testing ×1
filtering ×1
hover ×1
html ×1
html5 ×1
ios ×1
jquery ×1
karma-runner ×1
protractor ×1
ruby ×1
scroll ×1
toggle ×1
touch ×1