zoukankan      html  css  js  c++  java
  • angularJs的各种服务和指令的使用场景

    $location服务,获取页面跳转带的参数

    比如说页面是这样的  localhost:9102/admin/goods.html#?id=123   如何获取这个id=123的值呢?????(注意:angularJs页面跳转必须是#?key=val  这种  切记)

    1. 在controller 中引入  $location 服务 
    2. 在需要的方法中添加这样一句话就ok       var id=$location.search()['id'];   便可以得到id=123 了。

    ng-checked 指令

    ng-checked=true 表示被选中,false表示未选中

    ng-true-value  指令

    当我们点击checkbox 选中复选框时,ng-model 的绑定默认值是true,取消选中时为false.

    <input ng-model="checkboxModel" type="checkbox" >//选中时,checkboxModel 等于 true

    如果我们需要获取的值为字符串或者数字呢?

    那么就需要用到 ng-true-value 和ng-false-value

    选中checkbox 时:

    <input ng-model="checkboxModel" type="checkbox" ng-true-value=" 'hello wolrd' " > //注意 ng-true-value 中的值 如果需要显示字符串的话必须使用单引号

    取消选中checkbox 时:

    <input ng-model="checkboxModel" type="checkbox" ng-false-value=" 'bye bye' " > 
  • 相关阅读:
    利用docker搭建测试环境--安装
    fiddler获取手机请求
    python多线程
    linux下安装python的第三方module
    shell编程sed笔记
    shell 函数
    mysql information_schema 数据库简介:
    shell常用的判断条件
    gulp:gulp-sass基础教程
    (六):关于全局config配置
  • 原文地址:https://www.cnblogs.com/coder-lzh/p/9158214.html
Copyright © 2011-2022 走看看