angularjs-scope

How to update Directive on State Changes

穿精又带淫゛_ 提交于 2019-12-22 09:44:08
问题 I have a root state that defines the overall structure of the Angular template. In the root state, I have the sidebar included that has dynamic menus via directive that changes based on the state. Like this: .state(‘root', { abstract: true, url: ‘/root', templateUrl: ‘views/root.html', }) root.html includes the sidebar.html that has dynamic menu called through Directive like this: sidebar.html <ul class="nav" id="side-menu"> <li class="nav-header"> <img alt="avatar" ng-src="{{ avatar }}" /> <

How to access ng-model value in controller of popup model in angular?

我们两清 提交于 2019-12-22 09:24:08
问题 I want to access an ngModel from within a controller, but here the ngModel is defines in a popup input field. I want to access the qty and name values in controller. Note that this whole code is model popup. Model code <ion-modal-view> <ion-header-bar> <h1 class="title">Item Details</h1> </ion-header-bar> <ion-content padding="true"> <form ng-submit="addItem()"> <div class="list list-inset"> <label class="item item-input"> <span class="input-label">Name</span> <input type="text" name="name"

How to handle $ctrl. in AngularJS?

房东的猫 提交于 2019-12-22 08:30:15
问题 I have a Methode from an API. It returns a promise which resolves to an $ctrl(?) object. This objects should contain a measurement and will be updated whenever it receive a new data. getMeasurements.latest(filter) //only a object to filter through all measurements .then(function (latestMeasurement) { $ctrl.latestMeasurement = latestMeasurement; }); My problem is that I don't know how to work with this data or display it in my html file. How does $ctrl work? Here the documentation of the API

How to handle $ctrl. in AngularJS?

谁都会走 提交于 2019-12-22 08:29:26
问题 I have a Methode from an API. It returns a promise which resolves to an $ctrl(?) object. This objects should contain a measurement and will be updated whenever it receive a new data. getMeasurements.latest(filter) //only a object to filter through all measurements .then(function (latestMeasurement) { $ctrl.latestMeasurement = latestMeasurement; }); My problem is that I don't know how to work with this data or display it in my html file. How does $ctrl work? Here the documentation of the API

AngularJS +1.5 How can a Parent controller pass data to a component Controller

人走茶凉 提交于 2019-12-22 08:23:55
问题 I have a component like: Check Plunkr Example ( Updated and Working with the solution :) Thanks ) my-component.js declaration (function() { 'use strict'; angular .module('app') .component("myComponent", { bindings: { obj: "=" }, controller: "ComponentController", controllerAs: "vm", template: '<section class="result"><h2>{{vm.title}}</2>' + '<h3>Using the Parent Controller values</h3>' + '<ul><li>{{ vm.obj.a }}</li><li>{{vm.obj.b}}</li></ul>' + '<h3>Using the Children controller values:'+ '

AngularJS - binding/watching a function which returns a promise

℡╲_俬逩灬. 提交于 2019-12-22 08:07:56
问题 I posted an issue on the AngularJS github but it doesn't seem to be getting a whole lot of attention and I wasn't able to fix it myself since it's a pretty low-level issue, so I think it's time to look for a workaround. Angular allows you to put a promise (or anything with a .then(...) function) into your scope, and once it is resolved, all $watches and anything bound to that promise will use the resolved value. The issue arises when you use a function to return a promise, as the same doesn't

AngularJS : Initializing isolated scope inside a directive

眉间皱痕 提交于 2019-12-22 07:18:12
问题 I have created a directive that accepts some attributes and initializes the isolated scope with these attributes. If an attribute isn't specified, then the isolated scope should be initialized with a calculated value. I added a link function that inspects the scope and initializes the default values (if no value has been set using the attributes). The scope has been initialized, but if I set a default value then it will be overwritten later by the framework. A workaround is to use $timeout(..

How does the createSpy work in Angular + Jasmine?

自作多情 提交于 2019-12-22 07:08:17
问题 I made a simple demo of a factory and I am trying to test this using jasmine . I am able to run the test but I am using the spyOn method. I would rather use jasmine.createSpy or jasmine.createSpyObj to do the same test. Could someone help me to refactor my code so that uses these methods instead in my example? http://plnkr.co/edit/zdfYdtWbnQz22nEbl6V8?p=preview describe('value check',function(){ var $scope, ctrl, fac; beforeEach(function(){ module('app'); }); beforeEach(inject(function(

Angular File Upload directive not updating controller model

删除回忆录丶 提交于 2019-12-22 05:49:06
问题 I am attempting to follow this [tutorial] but can't get it working. My Angular controller is logging undefined for a model created in my directive. Here is a [JSFiddle] of it working created my author of tutorial. The problem is the view can find $scope.myFile and but controller does not ( $scope.myFile is undefined ). The view displays {{ myFile.name }} (as just example my-image.jpg ). The myFile variable is a JS object containing data on selected file. This works fine. The directive seems

$locationChangeSuccess triggers four times

白昼怎懂夜的黑 提交于 2019-12-22 01:36:09
问题 I am new to angular Js. My application flow is as below: 1) I have a view controller wherein, each view controller sets the breadcrumb data with the help of Breadcrumbs factory. 2) Breadcrumbs factory takes data from view controller and attaches data to $location.$$state object.(reason for storing in state object is if back button is pressed, view controller doesn't instantiate so I can refer history data for breadcrumbs ) below is code to attach data to state object: var state = $location