<div my-directive my-url="http://google.com" my-link-text="Click me to go to Google"></div> angular.module('myApp', []) .directive('myDirective', function() { return { restrict: 'A', replace: true, scope: { myUrl: '@', //绑定…
vue.js中使用props down,events up的原则进行父子组件间的通信,先来记录下props down,看个例子: <div id="app2"> <child message="hello!"></child> </div> ... Vue.component('child', { // 声明 props props: ['message'], // 就像 data 一样,prop 可以用在模板内 //…
之前写过一篇backbone view之间的传递,由于现在在用angular搞开发,现在也来总结一下.在angular 传递数据通俗的讲叫做 广播 ,在一些文章中,也叫做事件的发布与订阅,在angular中通过 发布与订阅制定了数据的传递,使用时,在出发点广播事件,这个事件后面的参数是传递的数据,在适当的位置去进行接收,具体到开发中,对应着$scope和$rootScope的$emit.$broadcast和$on方法.首先了解一下概念: 1.$scope与$scope之间的关系,$scope与…
公司的项目前端部分现在改用angular,一切从头学起,今天记录一下关于数据请求的问题,由于get的请求方式比较简单,与post也类似,所以就单独讲讲post方式. 文档上post数据的写法有好几种,都是利用$http模块,通用写法如下: // Simple GET request example: $http({ method: 'GET', url: '/someUrl' }).then(function successCallback(response) { // this callbac…
在springmvc中controller的结果集可通过json格式传到js前端接受,也可以通过Map传给前端,具体实现如下 1,通过json格式传递 controller层实现如下 @RequestMapping("queryCityInfo") @ResponseBody public String queryCityInfo()throws Exception{ String provinceId = getString("id"); @SuppressWar…
一.编写service,修改数据要根据ID回显数据 //根据ID查询 public Brand findById(Long id); //修改 public int update(Brand brand);二.编写serviceImpl @Overridepublic Brand findById(Long id) { return brandDao.selectByPrimaryKey(id);} @Overridepublic int update(Brand brand) { return…
一.编写实体类Controller层返回数据使用 package entity; import java.io.Serializable; public class Result implements Serializable{ private static final long serialVersionUID = -8946453797496982517L; private boolean success; private String message; public Result(bool…
ng-style   <input type="button" value="set color" ng-click="myStyle={color:'red'}"> <input type="button" value="set background" ng-click="myStyle={'background-color':'blue', color: 'black'}&q…
1.angular.js 作为后起之秀的前端mvc框架,他于传统的前端框架都不同,我们再也不需要在html中嵌入脚本来操作对象了.它抽象出了数据模型,控制器及视图. 成功解耦了应用逻辑,数据模型,视图. 2.它的视图也不是后台统一替换后渲染页面,而是视图被动态实时替换. 视图上可以通过指定的 angular.js 指令来绑定模型数据.模型数据的变化又会直接影响视图的变化. 3.控制器就像一座桥梁,负责连接模型和视图, 模型里包括数据和与数据进行交互的方法. 视图只负责把模型数据的映射显示给用户.…
Angular JS的强大功能就在于其可以自定义很多指令,现在就指令做一下详细的剖析. 一个Angular js 指令(directive)需要指定一个唯一的名字(myDirective)和一个函数,其中返回一个对象,该对象包含该指令应有的一些行为,具体参见如下所有的属性. angular.module('myApp', []) .directive('myDirective', function() { return { restrict: String, priority: Number,…