小编use*_*392的帖子

选中复选框时使用ng-model创建数组

我是angularjs的新手,想要点击复选框时创建模型数组,下面是我的代码..

$scope.selectedAlbumSongs = [{
    'name': 'song1',
        'url': 'http://test/song1.mp3'
}, {
    'name': 'song2',
        'url': 'http://test/song2.mp3'
}, {
    'name': 'song3',
        'url': 'http://test/song3.mp3'
}];
$scope.playList = {};
Run Code Online (Sandbox Code Playgroud)

HTML:

<fieldset data-role="controlgroup">
    <legend>Select songs to play</legend>
    <label ng-repeat="song in selectedAlbumSongs">
        <input type="checkbox" name="{{song.url}}" id="{{song.name}}" ng-model="playList[song.url]">
        <label for="{{song.name}}">{{song.name}}</label>
    </label>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

当我单击复选框时,上面的代码更新了playList,如下所示

{
    "http://test/test1.mp3": true,
    "http://test/test2.mp32": true,
    "http://test/test3.mp3": false
}
Run Code Online (Sandbox Code Playgroud)

但我想以下面的格式创建ng-model,并在取消选中该复选框时删除该对象(例如,如果取消选中song3,则从该数组中删除song3对象).你能告诉我怎么写这个逻辑吗?

预期:

[{
    name: "song1",
    url: "http://test/song1.mp3"
}, {
    name: "song2",
    url: "http://test/song2.mp3"
}]
Run Code Online (Sandbox Code Playgroud)

angularjs angularjs-scope angularjs-ng-repeat

28
推荐指数
1
解决办法
5万
查看次数

如何使用Mustache模板向下拉列表添加选项?

这是我的javascript对象,我想添加选项到下拉列表?我希望属性名称作为值和属性值在每个选项中作为文本?

{ "": "", "CSharp40": "C# 4.0", ".NET": ".NET", "JQuery": "JQuery", "Javascript": "Javascript" }
Run Code Online (Sandbox Code Playgroud)

输出如下

<select id="courses"> 
    <option value=""></option>
    <option value="CSharp40">C# 4.0</option>
    <option value=".NET">.NET</option>
    <option value="JQuery">JQuery</option>
    <option value="Javascript">Javascript</option>
</select>
Run Code Online (Sandbox Code Playgroud)

你能告诉我如何为此编写Mustache模板吗?提前致谢

javascript jquery templates mustache

5
推荐指数
2
解决办法
4326
查看次数

Log4net preserveLogFileNameExtension not working

this is my log4net configuration, the rollover log file is created wrong extension. The first file created with name of log_debug.txt and the rollover file created with log_debug.txt.1. but ideally it should be log_debug.1.txt.

I used preserveLogFileNameExtension value to be true, but it seems not working. Can you please check and let me know if anything wrong?

<appender name="DebugRollingFileAppender" type="log4net.Appender.RollingFileAppender,log4net">
    <filter type="log4net.Filter.LevelRangeFilter">
      <levelMin value="DEBUG" />
      <levelMax value="DEBUG" />
    </filter>
    <file value=".\logs\log_debug.txt" />
    <appendToFile value="true" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="20" …
Run Code Online (Sandbox Code Playgroud)

log4net log4net-configuration log4net-appender

5
推荐指数
1
解决办法
4770
查看次数

标签文本溢出时应用省略号

在下面的html设计中,我想将文本溢出应用于省略号,用于媒体播放和备注标签,并希望第一行播放的媒体(第一个大行)和备注(第二个bing行)将继续下一个线.播放和停止以及媒体播放和备注都应该属于同一行.你能帮帮我吗?

.oneline {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#player-play, #player-stop
{
   display: inline-block;
   width: 48px;
   height: 48px;
}
#player-play
{
    background-image: url('../images/play.png');
}
#player-stop
{
   background-image: url('../images/stop.png');
}


 <div  id="player" data-role="header">
        <div data-role="navbar">
            <ul>
                <li class="oneline">
                    <a href="#" id="player-play" title="Play / Pause" style="float:left" ></a>
                    <a href="#" id="player-stop" title="Stop" style="float:left" ></a>
                    <label id="media-played" class="oneline">first big line first bing line first bing line first big line</label>
                    <label id="remarks">second big line second big line second big line second big line</label>
                </li> …
Run Code Online (Sandbox Code Playgroud)

css css3 css-float jquery-mobile

4
推荐指数
1
解决办法
1万
查看次数

Web.config 重写规则导致错误“页面的相关配置数据无效”

我收到错误“无法访问请求的页面,因为该页面的相关配置数据无效。” 当我在 WCF 应用程序的 web.config 中使用重写元素时。

<rewrite>
  <rules>
    <rule name="Rewrite Index">
      <match url="myApplicaiton/Healthcheck.aspx" />
      <action type="Redirect" url="HealthCheck.aspx" />
    </rule>
  </rules>
</rewrite>  
Run Code Online (Sandbox Code Playgroud)

如果请求 url 包含“myApplication” http://localhost/myApplication/HealthCheck.aspx我想要重定向(服务器重定向)。您能否告诉我上述配置是否有任何问题,并让我知道是否有其他方法对 WCF 应用程序 web.config 中的静态文件进行重定向

asp.net asp.net-mvc wcf asp.net-web-api

4
推荐指数
1
解决办法
1830
查看次数

在XML中使用targetNamespace

如何targetNamespace在XML中使用?一些真实例子的解释会很棒.

xml xsd

3
推荐指数
1
解决办法
4269
查看次数

SetTimeout函数仍然使UI无响应,直到其操作结束

我用setTimeout函数包装了长时间运行的逻辑(longLoop),但是在长时间运行执行之前,UI仍然没有响应.它不允许单击其他UI按钮.请查看下面的示例,如果您看到任何问题,请告诉我.

function longLoop () {
    var startLogTime, endLogTime;
    startLogTime = new Date().getTime();
    console.log("loop begin");
    for (var i = 0; i <= 500000000; i++) {
        var j = 10;
    }
    endLogTime = new Date().getTime();
    console.log("loop execution takes " + (endLogTime - startLogTime) + " milliseconds");
}

$(document).ready(function () {

    $("#btnButton").bind("click", function () {
        setTimeout(longLoop, 15);

    });

    $("#anotherButton").bind("click", function () {
        console.log("another operation clicked");
    });
});

<input type="button" id="btnButton" value="Start Long Operation" />
<input type ="button" id="anotherButton" value= "Another operation" />
Run Code Online (Sandbox Code Playgroud)

谢谢

javascript jquery

1
推荐指数
1
解决办法
1099
查看次数