小编Wéd*_*uri的帖子

导航Bewteen Partials后保持复选框检查

我正在建立一个单页幻想足球应用程序,每个位置都有部分页面,并显示一个玩家列表.

我想在每个玩家旁边实现一个复选框,当玩家被选中时,我可以选中复选框并让一条线路通过该玩家的名字.

我在浏览应用程序时检查复选框时遇到问题.当我浏览页面时,复选框的状态将丢失.我不确定如何在Angular.js中实现它.

以下是我的测试应用程序的代码.

的index.html

<!DOCTYPE html>
<html>

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular-route.min.js"></script>
<script src="script.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://rawgithub.com/gsklee/ngStorage/master/ngStorage.js"></script>
<script src="jquery.cookie.js"></script>
</head>

<body ng-app="RoutingApp">
    <h2>AngularJS Routing Example</h2>
    <p>Jump to the <a href="#first">first</a> or <a href="#second">second page</a></p>
    <div ng-view>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

first.html

<!DOCTYPE HTML>
<html>
  <head>
    <script src="jquery.cookie.js"></script>
    <meta charset="utf-8">
    <title>Persist checkboxes</title>
    <style>
    button{
      margin-top:8px;
    }
    </style>
  </head>

  <body>
  <h1>First Page</h1>
    <div>
      <label for="option1">Option 1</label>
      <input type="checkbox" id="option1">
    </div>
    <div>
      <label for="option2">Option 2</label> …
Run Code Online (Sandbox Code Playgroud)

html javascript angularjs angularjs-routing

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

Javascript正则表达式在_和 - 之间找到字符串

我正在尝试使用正则表达式来获取en字符串的一部分word_en-gb

我正在使用.match();eg

var string = "word_en-gb";
string.match(/(?<=\_)(.*?)(?=\-)/);
Run Code Online (Sandbox Code Playgroud)

(?<=\_)(.*?)(?=\-)可以工作,regex101.com但当我在我的代码中使用它时,我得到错误Uncaught SyntaxError: Invalid regular expression: /(?<=_)(.*?)(?=-)/: Invalid group

\_(.*?)\-匹配regex101但产生 _en-,en

javascript regex

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

标签 统计

javascript ×2

angularjs ×1

angularjs-routing ×1

html ×1

regex ×1