我试图获得位于表格外的按钮的效果,这些按钮与它们影响的表格行一致。为此,我正在尝试使用伪元素。如果我在表格行上使用 :after ,我可以轻松实现这一点,但是如果我使用 before,它将伪元素视为表格行中的新 td 并将所有内容推送到一个 td 上,使表格未对齐。
<table class="saInstrcutionTable">
<thead>
<tr>
<th></th>
<th>Level</th>
<th>Title 1</th>
<th>Title 2</th>
<th>Title 3</th>
</tr>
</thead>
<tbody>
<tr class="saLevel">
<td><input type="checkbox" name="level1"></td>
<td>Level 1 Name</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr class="moveTableLevel">
<td><input type="checkbox"></td>
<td>1.01</td>
<td>A.Truck, B.Car, C. House</td>
<td>Say look at that, turn head and point</td>
<td>CLorem ipsum</td>
</tr>
<tr class="moveTableLevel">
<td><input type="checkbox"></td>
<td>1.02</td>
<td>A.Truck, B.Car, C. House</td>
<td>Say look at that, turn head and point</td>
<td>CLorem ipsum</td>
</tr>
<tr class="moveTableLevel">
<td><input type="checkbox"></td>
<td>1.03</td> …Run Code Online (Sandbox Code Playgroud) 在我的react/redux应用程序中,我使用以下内容在reducers中设置状态:
state.set('search', myResults);
Run Code Online (Sandbox Code Playgroud)
国家是不可改变的Map().在运行toJS()时对象的格式(不再是不可变对象)是这样的:
{
results: { ..all results in here }
}
Run Code Online (Sandbox Code Playgroud)
所以你有state.search.results.
这很好用,但我有一个场景,我需要"推"到这张地图的搜索部分.我认为合并将照顾这一点,但它似乎没有像我想象的那样工作.我试过了 :
state.mergeIn('search', singleResult);
Run Code Online (Sandbox Code Playgroud)
以及
state.merge({ 'search': singleResult });
Run Code Online (Sandbox Code Playgroud)
似乎都没有工作.预期的结果是将单个结果推入状态Map()(而不是像其一样覆盖它.set).所以期望的结果最终看起来像这样:
{
results: { singleResult pushed or merged into here with other results }
}
Run Code Online (Sandbox Code Playgroud)
我不确定如何使用immutablejs,任何建议将不胜感激.谢谢!
我似乎在将json从我的工厂发送到控制器时遇到了问题
这是我的工厂
.factory("UserService", function($http) {
var LevelsHere;
$http.get("/assets/images/generated.json").success(function(data){
LevelsHere = data;
return LevelsHere;
});
return {
all: function() {
return LevelsHere;
},
first: function() {
return LevelsHere[0];
}
};
})
Run Code Online (Sandbox Code Playgroud)
我只是试图用这个工厂发送json对象(或者它的一部分).我可以在http get里面调试console.log似乎抓住了json就好了.我似乎已经撞墙了,任何帮助都会非常感激.我希望所有广告的第一个功能都能正常运行.谢谢!
我首先通过使用json字符串硬编码levelHere来获得成功,例如var levelsHere = [{"stuff in here"}],但是当我将它移到$ http时它不起作用.
我试图传入一个变量作为索引来设置一个活动行与一点点jquery.我的变量存储正确,但似乎无法让jquery接受参数中的变量.
这是我得到的:
$(this).find("td:eq('storeDex')").addClass("activeRow");
Run Code Online (Sandbox Code Playgroud)
storeDex是变量,如果我放下一个正常的数字,它似乎工作正常,我想也许我需要逃避可变的一些如何,但我似乎无法弄清楚如何做到这一点.任何帮助将非常感激.谢谢!
我正在尝试观察一个范围,以便每次都可以重新运行一个函数,但它似乎并没有像我想象的那样工作。
所以我只有
$scope.user = userFactory.getUser();
Run Code Online (Sandbox Code Playgroud)
我的用户被从工厂拉进来
然后稍后在单击功能中,我通过让用户单击按钮将其更改为其他内容,如下所示
$scope.swapUserTest = function(){
$scope.user = {'name' : 'new'}
}
Run Code Online (Sandbox Code Playgroud)
然后我试图只是观察它是否发生变化 - 这不仅仅是点击,将来它将来自多个不同的事物,所以我想监视它,以便每当它改变时我的函数就会触发。像这样的东西:
$scope.$watch($scope.user, function() {
console.log("changed")
});
Run Code Online (Sandbox Code Playgroud)
所以我假设,每当 $scope.user 更改时,它都会触发,但它似乎只有在它第一次从工厂进入控制器时才会触发。可以在这里使用一些指导。谢谢你!
我正在为我的一些函数编写单元测试,而测试运行器似乎有一个绑定函数的问题。我正在绑定一个函数,所以我在内部函数中引用了 this 。这是代码:
loadStates: function(name, stateName, options) {
if (myModule.getModule(name) !== undefined) {
this.prepState(name, stateName, options);
} else {
var bindForCheck = this.prepState.bind(this);
//module cannot be found check for 5 seconds
$log.warn("Requesting " + name + "...");
var timeToCheck = true;
setTimeout(function() {
timeToCheck = false;
}, 5000);
var check = {
init: function() {
check.checkAgain();
},
checkAgain: function() {
if (timeToCheck) {
if (myModule.getModule(name) !== undefined) {
bindForCheck(name, stateName, options);
} else {
//still doesn't exists
setTimeout(check.checkAgain, 200);
} …Run Code Online (Sandbox Code Playgroud) 我正在尝试为服务设置测试工具,使前端大约需要1秒钟才能播放一些东西。
我正在使用aq,所以我可以在控制器中调用.then,所以我发疯了,现在可以通过使用set timeout来伪造它,但是我认为我的语法不正确。这是我尝试过的:
return $q(function(resolve, reject) {
setTimeout(function() {
}, 1000).then(resolve);
});
Run Code Online (Sandbox Code Playgroud)
我只希望它等待一秒钟然后解决。对此新手,将不胜感激任何意见,谢谢!
我有一个react/redux应用程序,我有一些过滤和搜索.由于API的设置方式,我必须在接收过滤器然后发送新的搜索查询之间做一些基础工作.所以我有一个有效过滤器的小参考图,每次检查或取消选中过滤器时都会更新.问题是,我希望运行更新过滤器的操作,然后在此之后用新的过滤器参数调用服务器的操作,我不确定这个工作流程是如何进入redux的.
所以我调用了动作,然后它以更新的状态命中减速器,如此 -
case actions.TOGGLE_FILTER:
return toggleFilter(state, action);
var toggleFilter = function(state, action){
var currentFilters = state.toJS().activeFilters || {};
var removeFilterFromActive = function(item) {
if(item != action.filter.search){
return;
}
}
//already exists, remove from list (toggle off)
if (currentFilters[action.filterGroup.parentSearch] && currentFilters[action.filterGroup.parentSearch].indexOf(action.filter.search) > -1) {
var itemIndex = currentFilters[action.filterGroup.parentSearch].indexOf(action.filter.search);
currentFilters[action.filterGroup.parentSearch].splice(itemIndex, 1);
} else {
//add to obj
var newObj = {};
if (currentFilters[action.filterGroup.parentSearch]) {
currentFilters[action.filterGroup.parentSearch].push(action.filter.search);
} else {
newObj[action.filterGroup.parentSearch] = [];
newObj[action.filterGroup.parentSearch].push(action.filter.search);
_.extend(currentFilters, newObj);
}
}
return state.set('activeFilters', fromJS(currentFilters));
};
Run Code Online (Sandbox Code Playgroud)
所以这组装我的 …
所以我试图将一个布尔数组转换为一个字符串数组(只有被设置为true的布尔值).这可以是javascript或下划线.让我告诉你我的意思.
我有这样一个数组:
[{"item1" : [{"one": true, "two": false}]}, {"item2" : [{"one": false, "two": true}]}];
Run Code Online (Sandbox Code Playgroud)
我要找的最终结果是:
[{"item1" : ["one"]}, {"item2" : ["two"]}];
Run Code Online (Sandbox Code Playgroud)
值得一提的是,所有这些键都是动态的.我似乎无法想象我应该如何遍历此数组来完成此任务.越简单越好!谢谢!
这是我的不良尝试:
$scope.testObject = _.map($scope.filterArray, function(obj) {
_.map(obj.values, function(value) {
if (value === true) {
return value;
}
});
});
Run Code Online (Sandbox Code Playgroud)
(这不起作用).我想要完成的是将这些对象的值(例如[{"one":true,"two":false}]转换为字符串数组,字符串是设置为的项的键真正.
所以举个例子
[{"one":true, "two": false}]
Run Code Online (Sandbox Code Playgroud)
会变成
["one"]
Run Code Online (Sandbox Code Playgroud)
因为两个是假的.
有一点麻烦,我的反应/的WebPack成立,JSX的第一位击中,我"意外的标记" - 在第一<在JSX.这是我的Webpack配置:
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
'./app/index.jsx'
],
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
}]
},
resolve: {
extensions: ['', '.js', '.jsx']
},
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
filename: 'bundle.js'
},
devServer: {
contentBase: './dist',
hot: true
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
Run Code Online (Sandbox Code Playgroud)
};
我注意到如果我交换加载器使用react-hot,它不再知道如何读取es6导入:
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
include: path.join(__dirname, 'src'),
loader: 'react-hot!babel'
}]
},
Run Code Online (Sandbox Code Playgroud)
(给出错误 - …
javascript ×8
angularjs ×4
reactjs ×2
redux ×2
arrays ×1
babeljs ×1
css ×1
factory ×1
html ×1
immutable.js ×1
jquery ×1
karma-runner ×1
webpack ×1