angularjs

Pass object to component

删除回忆录丶 提交于 2021-01-26 19:49:48
问题 I have created a component that needs to have a reference to the object for which the component was created. I didn't make to work and all my trials have failed. Below, I try to describe the intention. The component definition would maybe look like this: angular .module('myModule') .component('myComponent', { templateUrl: "template.html", controller: [ MyController ], bindings: { myObject: '=' } }); function MyController(myObject) { var vm = this; vm.myObject = myObject; } In a service I

Pass object to component

强颜欢笑 提交于 2021-01-26 19:49:11
问题 I have created a component that needs to have a reference to the object for which the component was created. I didn't make to work and all my trials have failed. Below, I try to describe the intention. The component definition would maybe look like this: angular .module('myModule') .component('myComponent', { templateUrl: "template.html", controller: [ MyController ], bindings: { myObject: '=' } }); function MyController(myObject) { var vm = this; vm.myObject = myObject; } In a service I

Pass object to component

两盒软妹~` 提交于 2021-01-26 19:48:35
问题 I have created a component that needs to have a reference to the object for which the component was created. I didn't make to work and all my trials have failed. Below, I try to describe the intention. The component definition would maybe look like this: angular .module('myModule') .component('myComponent', { templateUrl: "template.html", controller: [ MyController ], bindings: { myObject: '=' } }); function MyController(myObject) { var vm = this; vm.myObject = myObject; } In a service I

Angular6 学习笔记——路由详解

北慕城南 提交于 2021-01-24 01:24:58
angular6.x系列的学习笔记记录,仍在不断完善中,学习地址: https://www.angular.cn/guide/template-syntax http://www.ngfans.net/topic/12/post/2 系列目录 (1) 组件详解之模板语法 (2) 组件详解之组件通讯 (3) 内容投影, ViewChild和ContentChild (4) 指令 (5) 路由 路由存在的意义 一般而言,浏览器具有下列导航模式: 在地址栏输入 URL,浏览器就会导航到相应的页面。 在页面中点击链接,浏览器就会导航到一个新页面。 点击浏览器的前进和后退按钮,浏览器就会在你的浏览历史中向前或向后导航。 那么,在angular中,是什么决定上述的行为呢? 对于一个新建的项目而言,只存在一个组件AppComponent,如果不增加其他的组件,意味着所有的行为就将在这一个组件里面完成,这种情况下,单一的组件将无法保存状态的变化,这显然满足不了上面的需求.所以,通常情况下,会如我在 组件通讯 中所写,组件之间呈如下的树形结构: 路由就是连接这些组件的筋络,它也是树形结构的.有了它,就可以在angular中实现上述的导航模式 可以把路由看成是一组规则,它决定了url的变化对应着哪一种状态,具体表现就是不同视图的切换 在angular中,路由是非常重要的组成部分, 组件的实例化与销毁

Angularjs : Using common service in different modules

本秂侑毒 提交于 2021-01-23 11:10:09
问题 I am trying to use the same service for different modules. There are many modules so i tried to inject them in a parent module. Something like this: var app=angular.module('myapp',['module_1','module_2',....,'module_n']); var module_1=angular.module('myapp1',[]); var module_2=angular.module('myapp2',[]); var module_3=angular.module('myapp3',[]); . . . var module_n=angular.module('myappN',[]); and the service which is common to all the n modules is like this: .service('myService',function(){ .

Angularjs : Using common service in different modules

点点圈 提交于 2021-01-23 11:06:46
问题 I am trying to use the same service for different modules. There are many modules so i tried to inject them in a parent module. Something like this: var app=angular.module('myapp',['module_1','module_2',....,'module_n']); var module_1=angular.module('myapp1',[]); var module_2=angular.module('myapp2',[]); var module_3=angular.module('myapp3',[]); . . . var module_n=angular.module('myappN',[]); and the service which is common to all the n modules is like this: .service('myService',function(){ .

Angularjs : Using common service in different modules

若如初见. 提交于 2021-01-23 11:04:24
问题 I am trying to use the same service for different modules. There are many modules so i tried to inject them in a parent module. Something like this: var app=angular.module('myapp',['module_1','module_2',....,'module_n']); var module_1=angular.module('myapp1',[]); var module_2=angular.module('myapp2',[]); var module_3=angular.module('myapp3',[]); . . . var module_n=angular.module('myappN',[]); and the service which is common to all the n modules is like this: .service('myService',function(){ .

JavaScript/Angular 1 - Promise.all to async-await

£可爱£侵袭症+ 提交于 2021-01-23 07:47:45
问题 I assign two calls to the web service in two variables in referencesPromise and contactTypesPromise $onInit() (I can create a new method for that, if needed) $onInit() { const referencesPromise = this.ReferenceService.getMultipleReferences(this.AgentReferences) const contactTypesPromise = this.ContactService.getContactTypes() Promise.all([referencesPromise, contactTypesPromise]).then((responses) => { this.references = responses[0] this.contactTypes = responses[1] const stateParams = this.

如何利用 React Hooks 管理全局状态

不想你离开。 提交于 2021-01-22 18:01:43
来源 | https://www.cnblogs.com/xhyccc/p/14242492.html React 社区最火的全局状态管理库必定是 Redux,但是 Redux 本身就是为了大型管理数据而妥协设计的——这就会让一些小一点的应用一旦用上 Redux 就变得复杂无比。 后来又有了 Mobx,它对于小型应用的状态管理确实比 Redux 简单不少。可是不得不说 Mobx+React 简直就是一个繁琐版本的 Vue。所以我也不太喜欢,不如直接用 Vue3。 总而言之,不管是 react-redux 还是 mobx,他们使用的时候都非常复杂,甚至需要你去组件函数或是组件类上修修改改,从审美角度上来说就令人不太喜欢。 直到后来某一天用了 Angular,我就开始对 SOA 产生好感,ng 的 Service 的写法与依赖注入控制反转着实惊艳到了我。 Service 是 Angular 的逻辑复用方法,并且解决了共享状态的问题,那 React 的自定义 Hook 可以达到类似的效果嘛? 可以,并且会比 Angular 更简洁!!! 什么是 Service 我们先来想一下,Service 到底是什么? Service 包含 n 个方法; Service 包含有状态; Service 应该是个单例。 这些方法与状态应该是高度整合的,一个 Service 解决的是一个模块的问题。

使用RxJs WebSocket,HighCharts和Angular实时数据

…衆ロ難τιáo~ 提交于 2021-01-21 14:04:12
Highcharts 是一款纯JavaScript编写的图表库,为你的Web网站、Web应用程序提供直观、交互式图表。当前支持折线、曲线、区域、区域曲线图、柱形图、条形图、饼图、散点图、角度测量图、区域排列图、区域曲线排列图、柱形排列图、极坐标图等几十种图表类型。 点击下载Highcharts最新试用版 在本教程中,我们将向您展示如何使用RxJs Websocket和官方的Highcharts Angular包装器可视化实时更新。您可以通过单击此GitHub链接访问整个项目。 备注 在本文中,使用随机数据来更新图表。没有服务器端代码的实现。 创建此项目有两个主要部分: 第一部分是设置Angular项目。为此,请遵循此Angular指南中的标准说明:设置本地环境和工作区。 第二部分是通过以下三个简单步骤来使用RxJsWebSocket和Highcharts设置Angular项目: 步骤1 由于我们将使用默认协议WSS(WebSocket协议),因此配置项目中的第一步是WebSocket import {webSocket}从rxjs/webSocket包中导入。 顺便说一句,如果你不熟悉WSS,这里是当有订阅的插座会发生什么的简短说明: 该rxjs管是用于撰写运营商的方法。订阅时收到的Emitted值仅被推入数组中并分配给data属性