【浅谈AngularJS中使用$resource(已更新)】教程文章相关的互联网学习教程文章

javascript – 模型不会在Angular 2电台列表中更新【代码】

我正在尝试构建一个Angular 2组件,它显示带有无线电的选项列表.它工作正常,但是在[(ng-model)] =“answer”中绑定的组件的答案字段在选择其中一个选项时不会更新.我做错了什么,或者这不是创建无线电选择列表的方法吗?<div>Answer: {{ answer }}</div><div class="radio" *ng-for="#option of itemData"><label><input type="radio" [value]="option.id" [(ng-model)]="answer"(change)="responseChanged()" name="radio-list"><sp...

javascript – Angular2:[routerLinkActive] =“[‘active’]”不在_router.navigate上更新【代码】

我有一个带有几个routerLinks的应用程序,我用[routerLinkActive] =“[‘active’]”设置它们.当我通过单击其中一个routerLinks导航时,一切正常.当我使用导航时: this._router.navigate([thisUrl],{queryParams:queryParams}); routerLinkActive停止工作.有谁知道如何解决这个问题? 我正在使用angular2 2.4.1解决方法:尝试this._router.navigate( [ thisUrl ], {queryParams: queryParams, relativeTo: this.route } );其中this....

javascript – AngularJs为什么更新属性比更新varibale更好?【代码】

来自“ng-book”,它说:Due to the nature of JavaScript itself and how it passes by value vs. reference, it’s considered a best-practice in Angular to bind references in the views by an attribute on an object, rather than the raw object itself.…..In this case, rather than updating the $scope.clock every second, we can update the clock.now property. With this optimization, we can….我不知道为什么,因...

javascript – Angular google maps custom图标仅在标记更新时有效【代码】

当我添加带有图标的标记时,它会显示为默认标记,但是当我在一段时间内更新该位置时,它会开始显示为我想要的自定义图标. map.html<ui-gmap-google-map center="map.center"control="map.control"zoom="map.zoom"options="map.options"bounds="map.bounds"draggable="true"><ui-gmap-markersmodels="markerArray"coords="'self'"icon="'icon'"></ui-gmap-markers> </ui-gmap-google-map>map.js / addMarker(放置标记,默认图标)functio...

javascript – angular-meteor无法使用Meteor 1.3更新【代码】

我刚刚将流星应用程序更新为Meteor 1.3,但现在出现了一个错误,如下所示:Uncaught Error: [$injector:modulerr] Failed to instantiate module angular-meteor它打破了angular的功能,下面是初始化代码angular.module('myApp',['angular-meteor','ui.router','ionic','ngCordova']);我尝试去除角度流星,但是当角度初始化两次时它显示错误.解决方法:1 我也是.我花了30分钟才发现我的项目还没有恢复到以前的版本.目前还有解决方法吗?

javascript – 更新视图(DOM)后的调用方法(在Angular 2中)【代码】

假设我有以下指令:import {Directive, Input, OnChanges } from '@angular/core'@Directive({selector: 'select[my-select]' }) export class NbSelect implements OnChanges {@Input() ngModel;constructor() {}ngOnChanges(changes) {doSomeStuffAfterViewIsUpdated();}doSomeStuffAfterViewIsUpdated() {console.log(jQuery('select[my-select]').val()); // this should write the new value} }我在模板中的某个地方使用它:…...

javascript – angular-ui ui-calendar不更新事件源对象/ ng模型的更改【代码】

我正在使用angular-ui / ui-calendar将fullcalendar.js添加到角度应用程序中.(angularjs 1.3.10,fullcalendar 2.2.6,ui-calendar 0.9.0-beta.1,jQuery 2.1.3,moment 2.9.0& angular-moment 0.9.0) 在日历中,我使用dayClick作为datepicker类型函数: – 将所选日期写入范围(用于应用程序中的其他用途) – 使用所选日期更新Event Source Object事件数组 – 在日历上显示所选日期(即新更新的事件) 我完成前两个任务没有问题,但第三个没...

javascript – 为什么Angular在正确更新模型时,通过在ng-options中为标记添加“selected”属性来更新DOM?【代码】

当我构建一个< select>时使用Angular 1.2.29如果选择一个选项,模型会更新,并且在视觉上< select>表示已选择新选择的选项. 但是,当使用开发人员工具查看标记时,我可以看到选项标记未更新,具体而言,所选属性不会从先前选择的选项中删除,也不会添加到新选择的选项中.<div data-ng-controller="MainController as main"><pre> {{ main.test.item }} </pre><selectdata-ng-model="main.test.item"data-ng-options="item.label for item ...

javascript – Angular:工厂模型中的更新不会反映在控制器中【代码】

我有一个用户首选项工厂,它保存用户首选项值.页面加载时为空.用户登录后,用户配置文件填满.伪代码app.factory('pref', function($rootScope){var pref = {}, age, name; $rootScope.$on('logged.in', function(){pref.name = 'sam';pref.age = 30;pref.currency = '$';age = getAge(); name = getName();})function getName(){//format namereturn name;}function getAge(){return age;} return {currency: pref.currency,...

javascript – 在对firebase进行异步调用之后,Angular应用程序不会更新(脏检查)【代码】

我正在为我的博客使用单页角应用程序.在加载时,控制器会为我的firebase调用所有博客帖子,并将它们推送到$scope.posts数组中. HTML使用ng-repeat来显示每篇博文的片段.但是,除非用户激活页面上的任何其他随机函数以强制摘要循环,否则根本不会出现任何片段.如何在没有用户交互的情况下进行脏检查或强制摘要循环?angular.module('evancodes.main', []) .controller('MainController', function(Main, $http, $scope) {$scope.posts =...

javascript – Angular中数组的异步更新【代码】

我有一个视图,我在哪里呈现推文.在推文内部,有user_mentions数组.从这个数组中,我想获得一个用户,向API发出另一个请求,获取用户的头像,然后呈现它.视图看起来像:<md-item ng-repeat="item in content"><div class="md-tile-left" ng-if="item.show"><img ng-src="{{item.thumb}}" class="face" alt="{{item.name}}"></div><div class="md-tile-content">{{item.text}}</div> </md-item>内容变量将包含所有推文.最初,content [i] ....

javascript – Angular中的WebSocket服务更新范围(使用ngWebSocket)?【代码】

我正在尝试从websocket获取数据以自动更新控制器范围内的值. 我的服务:mimosaApp.service("Device", function ($websocket) {var self = this;var ws = $websocket.$new({url: "ws://" + window.location.host + ":81",//mock: true,reconnect: true});this.data = {};ws.$on("$open", function() {ws.$emit("get", "device");});ws.$on("$message", function (message) {console.log("WS Received", message);for(var key in mes...

javascript – 在内部更改Notification Factory模型后,Angular ng-repeat不会更新【代码】

在我的Angular应用程序中,我有一个简单的通知工厂,它允许我存储和获取我想传达给用户的信息:(function() {'use strict';angular.module('peaches').factory('NotificationFactory', factory);// factory.$inject = ['dependencies'];/* @ngInject */function factory() {var messages = [];var service = {postAlert: postAlert,getAlerts: getAlerts,deleteAlert: deleteAlert};return service;function postAlert(alert) {messa...

javascript – 当删除数组中的项目时,AngularJS ng-repeat没有正确更新【代码】

我面临的问题是我有一个ng-repeat,当我通过单击一个具有与删除数组中项目相关联的功能的按钮来删除项目时,ng-repeat没有正确显示实际数组. 该数组看起来像:['stuff', 'stuff', 'stuff', ....]删除项目时显示ng-repeat的是没有最后位置的数组,尽管我删除了第一个位置.当我执行console.log时,数组看起来正确,第一个位置或x位置被删除.解决方法:问题是:track by $index由于我一直在做的证明中有一些重复的图像.我删除它,它按预期工作...

javascript – 更换值时AngularJS视图不会更新【代码】

我有以下html:<input type="text" ng-model="skype" ng-change="checkInput('skype')">功能是:$scope.checkInput = function(value) {var string = $scope[value],pattern = /[^a-zA-Z]+/g;string = string.replace(pattern, ''); }现在,console.log显示该字符串已成功替换,但视图未更新.最奇怪的部分是使用子字符串时视图更新!string = string.substring(0, 10);怎么了?解决方法:您没有为范围设置任何值,以便角度可以观察并做...