小编Kru*_*cha的帖子

检查Angular中是否选中了复选框

如何检查此Angular示例中是否选中/选中了复选框?因此,当用户选择/选中第一个复选框我想要得到真正的,当取消选择/取消选中它,我想.

angular.module('app', [])
  .controller('Controller', function($scope) {
    $scope.toggleSelection = function toggleSelection() {
      // how to check if checkbox is selected or not

    };
  })
Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="Controller">
  <h1>Get checkbox selection (true/false)</h1>
  <label>
    <input id="one" type="checkbox" ng-click="toggleSelection()">This
  </label>
  <br>
  <label>
    <input type="checkbox" ng-click="toggleSelection()">That
  </label>
  <br>
  <label>
    <input type="checkbox" ng-click="toggleSelection()">Lorem
  </label>
  <br>
  <label>
    <input type="checkbox" ng-click="toggleSelection()">Ipsum
  </label>
</div>
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

8
推荐指数
2
解决办法
3万
查看次数

使用Vue.js异步/等待axios调用

设置我的一个,我有点麻烦.我的Vue.js应用程序中的值.我相信我要么不正确理解异步axios调用,要么在Vue.js中如何异步工作.

我有以下三种方法:

updateAvailability(availability) {
    if (availability == true) {
        this.showYourDetails();
    } else {
        this.showBookingDetails();
    }
},
checkAvailability: async function(event) {
    event.preventDefault();
    const availability = await this.handleAvailabilityRequest(event);
    this.loading = true;
    console.log(availability); //This evaluates to undefined
    const availabilityUpdate = await this.updateAvailability(availability);
    this.loading = false;
},
handleAvailabilityRequest: async function(event) {
    event.preventDefault();
    let valid = this.validateFieldsForAvailabilityRequest(); //Ignore this for this particular question, assume valid is always true

    if (valid) { // This is true
        let config = {
            headers: {
                "X-CSRFToken": this.csrfToken,
                "Content-Type": 'application/x-www-form-urlencoded', …
Run Code Online (Sandbox Code Playgroud)

javascript asynchronous async-await vue.js axios

8
推荐指数
2
解决办法
3万
查看次数

React recreates my component on each material ui tab switch

I added a Material UI Tabs component in my application, coding it almost similar to the one in their Simple Tabs demo.

I'm experiencing, though, that the components inside each tab — that is those at:

render() {
    /... 
    {
        value === 0 && < MyComponent1 / >
    } {
        value === 1 && < MyComponent2 / >
    } {
        value === 2 && < MyComponent3 / >
    }
    /...
}
Run Code Online (Sandbox Code Playgroud)

are being recreated (I can trace this with …

javascript tabs reactjs material-ui

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

将点击事件添加到数据表

这是我的Jquery数据表,用于从ajax获取值并放置它.

$(document).ready(function() {
    $('#example').DataTable({
        "ajax": "data/arrays.txt"
    });
});
Run Code Online (Sandbox Code Playgroud)

这是构造的表格.

我想写点击功能.我该怎么做 ?

<table id="example" class="table dataTable no-footer" role="grid" aria-describedby="example_info" style="width: 299px;">
    <tbody>
        <tr role="row" class="odd">
            <td class="sorting_1">TMB030</td>
            <td>Sample Collected</td>
        </tr>
        <tr role="row" class="even">
            <td class="sorting_1">TMB033</td>
            <td>Sample Collected</td>
        </tr>
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

我想将click事件写入role ="row"并获取其值TMB030.

我怎样才能做到这一点 ?

我试过这样的

$(document).ready(function() {
    $('#example').DataTable({
        "ajax": "myOrders/" + Cookies.get('userSession')
    });
    $("div[role='row']").click(function() {
        alert('clicked')
    });
});
Run Code Online (Sandbox Code Playgroud)

但它没有触发我怎么能这样做?请帮忙

html javascript php jquery datatables

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

控制器:ctrlfmt 格式错误的控制器字符串 ''。必须匹配 `__name__ 作为 __id__` 或 `__name__`

在 rootes.js 中

.state('main.mydata', {
    url: '/my-data',
    templateUrl: '/app/views/pages/my-data.html',
    controller: 'mydataCtrl'
})
Run Code Online (Sandbox Code Playgroud)

控制器

.controller('mydataCtrl', ['$scope', '$state', '$http', function($scope, $state, $http) {
    console.log("Came to My Data")
}])
Run Code Online (Sandbox Code Playgroud)

当我调用页面在控制台中出错时

Error: angular.js?bundleVirtualPath=~%2fbundles%2fangular:13708 [$controller:ctrlfmt] Badly formed controller string ''. Must match `__name__ as __id__` or `__name__`.
http://errors.angularjs.org/1.5.7/$controller/ctrlfmt?p0=
    at http://localhost:25282/Scripts/angular.js?bundleVirtualPath=%7eNaNbundles%fangular:68:12
    at $controller (http://localhost:25282/Scripts/angular.js?bundleVirtualPath=%7e%fbundles%fangular:10199:17)
    at setupControllers (http://localhost:25282/Scripts/angular.js?bundleVirtualPath=%7e%fbundles%fangular:9331:34)
    at nodeLinkFn (http://localhost:25282/Scripts/angular.js?bundleVirtualPath=%7e%fbundles%fangular:9116:32)
    at compositeLinkFn (http://localhost:25282/Scripts/angular.js?bundleVirtualPath=%7e%fbundles%fangular:8510:13)
    at nodeLinkFn (http://localhost:25282/Scripts/angular.js?bundleVirtualPath=%7e%fbundles%fangular:9210:24)
    at compositeLinkFn (http://localhost:25282/Scripts/angular.js?bundleVirtualPath=%7e%fbundles%fangular:8510:13)
    at compositeLinkFn (http://localhost:25282/Scripts/angular.js?bundleVirtualPath=%7e%fbundles%fangular:8513:13)
    at compositeLinkFn (http://localhost:25282/Scripts/angular.js?bundleVirtualPath=%7e%fbundles%fangular:8513:13)
    at publicLinkFn (http://localhost:25282/Scripts/angular.js?bundleVirtualPath=%7e%fbundles%fangular:8390:30)
Run Code Online (Sandbox Code Playgroud)

可能是什么问题?

angularjs

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

为什么在angularjs 2中更改布尔值时,ngOnchanges不会触发

我在这个问题上看到了类似的问题,但没有答案对我有用.我有一个布尔值,只要异步任务完成就会改变,但奇怪的是,ngonchages不会随时更改.以下是我的代码:

import {
    Component,
    OnChanges,
    SimpleChange
} from '@angular/core';
export class HomePage implements OnChanges {

    isLoaded: boolean;

    constructor() {
        this.isLoaded = false;
        this.loadData();
    }

    loadData() {
        setTimeout(() => {
            this.isLoaded = true;
            console.log(this.isLoaded);
        }, 3000);
    }

    ngOnChanges(changes) {
        console.log("There has been a change ", changes); //this is not firing
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript angular

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

反应原生相机 - 默认预览似乎在 IOS 上放大

我正在为我的应用程序使用 React Native Camera,但我遇到了一个奇怪的问题。

这是我的代码:

<View flex>
    <RNCamera ref={ref=> { this.camera = ref; }} style={{flex : 1}} type={this.state.cameraType} flashMode={RNCamera.Constants.FlashMode.on} permissionDialogTitle={'Autorisation de l\'appareil photo'} permissionDialogMessage={'Nous avons besoin de votre permission pour accéder à l\'appareil photo.'} zoom={0} ratio={'16:9'} focusDepth={0} />
    <View style={{ position: 'absolute', width: 75, height: 75, top: this.state.currentHeight / 2.2, bottom: 0, right: 37, zIndex: 1 }}>
        <TouchableOpacity centerH onPress={this.takePicture.bind(this)}>
            <Image style={{ width: 75, height: 75 }} source={{ uri: "cameraButton" }} />
        </TouchableOpacity>
    </View>
    <View style={{ position: 'absolute', width: 50, …
Run Code Online (Sandbox Code Playgroud)

javascript react-native react-native-ios

5
推荐指数
0
解决办法
496
查看次数

JavaScript 中的 SonarQube Regex 漏洞问题

无论我在 JavaScript 代码中使用 Regex 的任何地方,SonarQube 都会显示漏洞问题。JavaScript 中是否有 Regex 的替代方案?

错误 : Make sure that using a regular expression is safe here.

示例正则表达式: '(^(?=[A-Za-z0-9\._-]*$)(?=.*[A-Za-z0-9]).*$)'

javascript sonarqube

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

无法一次选择一个单选按钮

我无法一次选择一个单选按钮.正在选择多个按钮.我是html的新手.这是我的代码.请帮忙.

<form name="ans_a" onsubmit="return answer_a()">
    <table align="center" border="1">
        <br>
        <br>
        <tr>
            <td width="500px"> ABC 
                <br>
                <input type="radio" name="A" value="a" id="radio1"> A &nbsp Option A <br>
                <input type="radio" name="B" value="b" id="radio2"> B &nbsp Option B <br>
                <input type="radio" name="C" value="c" id="radio3"> C &nbsp Option C <br>
                <input type="radio" name="D" value="d" id="radio4"> D &nbsp Option D <br>
                <br>
                &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp
                <input type="button" name="ans1" value="Next" onclick="answer_a()">
            </td>
        </tr>
    </table>
</form>
Run Code Online (Sandbox Code Playgroud)

html

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

角js:ng-min \ng-max

我使用角度js,结合角度ui,在我的网站上显示模态窗口. HTML

<script type="text/ng-template" id="myModalContent.html">
    <div class="modal-header text-center">
        <h3 class="modal-title" id="modal-title">Jump to page</h3>
    </div>
    <div class="modal-body text-center" id="modal-body">
        <input type="number" ng-model="info.page" class="text-center" ng-enter="ok()" ng-min="{{info.min}}" ng-max="{{info.max}}" />
        <div>MAX: {{info.max}}</div>
        <div>MIN: {{info.min}}</div>
        <button class="btn btn-primary" type="button" ng-click="ok()" style="margin-top: 20px;">OK</button>
    </div>
</script>
Run Code Online (Sandbox Code Playgroud)

用户具有范围的填补输入号码info.maxinfo.min.

这里是相关的角度代码 - 触发模态窗口打开:

function gotoPageDialog(fileNo, current, max) {
    var modalInstance = $uibModal.open({
        templateUrl: 'myModalContent.html',
        controller: 'ModalInstanceCtrl',
        size: 'sm',
        resolve: {
            current_info: function() {
                return {
                    fileNo: fileNo,
                    page: current,
                    max: max,
                    min: 1
                }
            }
        } …
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

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