ITeye博客

angularjs

共 17 篇文章

React实现Angularjs ng-show、ng-if和ng-hide

添加一段用户登录场景,登录显示登录信息,否则显示非登录信息。 使用Angularjs我们可以这样做: <div class="logined" ng-show="isLogin">登录了</div> <div class="logined" ng-if="isLogin">你好,{userName}</div> <div class="no-login" ng-hide="isLogin">未登录</div> 那我们使用React要怎么去实现这样的场景呢? React.createClass({ getInitialState: function() { return { isLogin: …

2016-01-07 15:41 · js · angularjs · React · 乔乐共享 · 每天进步一点点

React实现Angularjs ng-class

首先设定一段Angularjs代码的ng-class: <i class="header-help-icon down" ng-class="{up:showMenu}"></i> 比较容易理解的Angularjs ng-class设置样式代码,那我们使用React怎么去实现它呢? // 首先在state设置一个变量比如: isShowLoginMenu,在不同场景改变它的值 // 然后在绑定在class样式上面 <i className={"header-help-icon down" + (this.state.isShowLoginMenu ? ' up' : '')}></i> or…

2016-01-07 15:30 · js · angularjs · React · 乔乐共享 · 每天进步一点点

Angularjs在线教程 全网发布 邀您共享

http://each.sinaapp.com/angular/ 技术分享: angular在线教程 百度搜索: angular在线教程 谷歌搜索: angular在线教程 AngularJS在线教程 1、AngularJS入门教程:启用应用(app) 2、AngularJS入门教程:数据双向绑定(model) 3、AngularJS入门教程:模块(module) 4、AngularJS入门教程:数据循环(repeat) 5、AngularJS入门教程:数据嵌套循环(nested-repeat) 6、AngularJS入门教程:数据过滤(filter) 7、AngularJS入门教程:数据过…

2015-10-27 17:59 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

Angularjs 双重循环获取父级下标$index

<table class="table table-bordered"> <tr ng-repeat="info in ttzInfo" ng-cloak> <td class="col-xs-2 adjust-col-2 text-right title-desc" ng-bind="info.title"></td> <td class="col-xs-3 adjust-col-3 text-center" ng-repeat="key in ['ttz', 'yeb', 'bank']"> <span ng-if="info[key]"> <span ng-if="info[key].…

2015-09-09 17:00 · angularjs · 乔乐共享 · AngularJS

Angularjs同步操作http请求with $promise

// Define a factory app.factory('profilePromise', ['$q', 'AccountService', function($q, AccountService) { var deferred = $q.defer(); AccountService.getProfile().then(function(res) { deferred.resolve(res); }, function(res) { deferred.resolve(res); }); return deferred.promise; }]); // use a factory /…

2015-07-02 15:49 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

AngularJs $scope function and Filter 异同

首先我们看这样一个实例: // Filter sl.filter('titleFilter', function() { return function(title, id) { var url = '/public/article#/' + id; return '<a href="' + url + '">' + title + '</a>'; }; }); 使用实例:(Works good) <h6 class="news-title" ng-bind="v.title | titleFilter:v.id"></h6> 另一实例:(Html插入, It doesn't work, W…

2015-02-05 10:35 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

AngularJs $stateProvider 链表循环追加实现参数化

Lib: https://github.com/angular-ui/ui-router 使用实例: // Some state name examples // stateName can be a single top-level name (must be unique). $stateProvider.state("home", {}); // Or it can be a nested state name. This state is a child of the // above "home" state. $stateProvider.state("home.newest",…

2015-02-04 17:17 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

Angularjs ng-selected 高端用法,针对json list

$scope.updateForm = {id: 33, code: "subwayLine2", name: "川沙"} <select class="form-control" ng-model="updateForm.code"> <option value="">--请选择--</option> <option ng-repeat="v in codeList" ng-selected="updateForm.code == v.code">{{v.code}}</option> </select> DEMO: http://each.sinaapp.com/angular/tuto…

2015-01-02 21:32 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

Angularjs ng-options循环json数据问题及解决方案

1、数据 [{"code":"subwayLine1"},{"code":"subwayLine2"},{"code":"subwayLine3"},{"code":"subwayLine4"},{"code":"subwayLine5"},{"code":"subwayLine6"},{"code":"subwayLine7"},{"code":"subwayLine8"}] 2、ng-options循环下拉列表 <select class="form-control" ng-model="code" ng-options="v.code for v in codeList"> <opti…

2015-01-02 20:36 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

Angularjs / js 正则格式化银行卡号

app.filter('splitNumberFilter', [function() { return function(content) { return content ? content.replace(/\s/g,'').replace(/(\d{4})(?=\d)/g,"$1 ") : content; } }]); // js版本 '1234567890123456'.replace(/\s/g,'').replace(/(\d{4})(?=\d)/g,"$1 "); // result "1234 5678 9012 3456" "5484815545215154548487…

2014-12-31 18:28 · js · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

AngularJs 禁止用户输入input,阻止事件运行

<div class="form-group"> <lable class="add-on">证件类型</lable> <span class="right-add-on sl-icon-mobile-lock"></span> <input type="text" name="idCardTxt" class="form-control" placeholder="身份证" maxlength="0" ng-keypress="$event.preventDefault()" ng-paste="$event.preventDefault()" onfocus="idCardTxt.blu…

2014-12-29 14:27 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

AngularJs 阻止事件运行,防止冒泡穿透事件

<body ng-controller="MainCtrl"> <div ng-click="goUrl('http://qiaole.sinaapp.com')"> <button type="button" ng-click="doSomeSth();$event.stopPropagation();">button</button> </div> </body> JS防止冒泡事件: http://qiaolevip.iteye.com/blog/2087911 更多实例应用扫码体验:

2014-12-24 10:52 · angularjs · 冒泡 · 乔乐共享 · 每天进步一点点

AngularJs 绑定html数据 ng-bind-html

1、内部域直接信任 <div ng-bind-html="preview_data.preview.embed.htmlSafe"></div> myApp.controller('myCtrl', ['$scope', '$sce', function($scope, $sce) { $scope.preview_data.preview.embed.htmlSafe = $sce.trustAsHtml(preview_data.preview.embed.html); } 2、内部域信任函数 <div ng-bind-html="to_trusted(preview_data.prev…

2014-12-19 11:01 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

【更新】AngularJs $location获取url参数

// 带#号的url,看?号的url,见下面 url = http://qiaole.sinaapp.com?#name=cccccc $location.absUrl(); // http://qiaole.sinaapp.com?#name=cccccc $location.host(); // qiaole.sinaapp.com $location.port(); // 80 $location.protocol(); // http $location.url(); // ?#name=cccccc // 获取url参数 $location.search().name; // or…

2014-11-12 14:36 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

angularjs获取nodejs response数据的两种方法

第一种解决方案: Nodejs服务端: router.get('/list', function(req, res) { employeeService.queryData(function(data) { var v = _.clone(mapping.employeeList); v.list = data; res.render(mapping.employeeList.view, v); }); }); Angularjs客户端: app.controller('EmployeeCtrl', ['$scope', function($scope) { }]); html页面设置数据(…

2014-11-04 18:07 · nodejs · angularjs · 乔乐共享 · 每天进步一点点

AngularJs directive使用自定义filter

/** * money formatter, will add <small> tag for the yuan and the decimal * <div ng-bind-html="number|slMoney [:shrink [:noHtml :decimalLength]]"></div> * */ sl.filter('slMoney',['$filter','$sce',function($filter,$sce) { /** * @number input number , by default (mostly used) : 32123.34 --> 32,123<sma…

2014-10-09 15:04 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点

AngularJs 三目运算 表达式判断

事件回顾:由于需要修改同一个模板,里面包含2个不同的内容,第一个里面使用的时间差和第二个里面名称不一样,其他过滤器,内容都大同小异。希望杜绝If这样比较傻的来判断if-show or not,继续追究其源码。 var b = "{{", a = "}}"; this.startSymbol = function(a) { return a ? (b = a, this) : b }; this.endSymbol = function(b) { return b ? (a = b, this) : a }; var Ca = b.startSymbol(), oa = b.endSymbol…

2014-09-10 14:53 · angularjs · 乔乐共享 · AngularJS · 每天进步一点点