angularjs-scope

AngularJS directive for dependant select element

試著忘記壹切 提交于 2019-12-25 01:36:32
问题 I'm trying to write a directive for dependant select elements. The relationship is Country > States > Cities . When element with class country get changed I should update element with class states and the same behavior for element with class city . To get the states I only need the country id and for get cities I need country and state id's. So I did this code: app.directive('country', ['$http', function($http) { return { restrict: 'C', link: function(scope, element, attrs) { element.change

Angularjs binding value from async service

核能气质少年 提交于 2019-12-25 01:34:15
问题 Having resolved a couple of errors thanks to @sehaxx in Angularjs binding value from service I would like introduce async in the example as in the following code where a variable is initialized asynchronously and it's value is not reflected in the view. (function(angular) { 'use strict'; angular. module('myServiceModule', []). controller('MyController', ['$scope', 'notify','$log', function($scope, notify, $log) { this.clickCount = 0; this.clickLimit = notify.clickLimit(); this.callNotify =

Is it possible to 'transclude' while keeping the scope of the directive in Angular?

人走茶凉 提交于 2019-12-25 00:39:24
问题 Is possible to do the following in Angular? <div ng-controller="MainCtrl" ng-init="name='World'"> <test name="Matei">Hello {{name}}!</test> // I expect "Hello Matei" <test name="David">Hello {{name}}!</test> // I expect "Hello David" </div> My directive is simple but it's not working: app.directive('test', function() { return { restrict: 'E', scope: { name: '@' }, replace: true, transclude: true, template: '<div class="test" ng-transclude></div>' }; }); I also tried to use the transclude

$scope inaccessible in nested function

ⅰ亾dé卋堺 提交于 2019-12-24 22:33:36
问题 I'm trying to build a service for geolocation in angularjs, however I wanted to give it a try in my controller first then move it out. Right now I'm not able to access the $scope variable when I get my position.coords.latitude/longitude values. Can someone explain to me why it's not accessible? I don't have in depth knowledge in javascript, but is it because parent variables aren't accessible for some reason? and What would be a good way to work around this kind of limitation? I'm tagging

Angular 1.6 component transclusion scope

烈酒焚心 提交于 2019-12-24 20:32:57
问题 I'm trying to figure out how to get data into a component transclusion in Angular 1.6.4. The scenario has a component, a directive (not re-written as a component yet) and a service for inter-component communication. angular.module('app') .service('svc', function() { this.connector = {}; }) .directive('first', ['svc', function($svc) { return { restrict: 'E', scope: { 'id': '@' }, template: '<button ng-click="GetData()">get data</button>', controller: ['$scope', 'svc', function($scope, $svc) {

AngularJS Controller resetting $scope variables after setting

╄→гoц情女王★ 提交于 2019-12-24 20:01:05
问题 I am trying to implement a simple datepicker using the akveo AngularJS project. When I change my date,I am setting a $scope variable from on-change function. When I debug, I can see that the correct picked value is being passed and $scope.simStartDate is actually changing to the set date. However, when I try to read it later, in ParamsFormBtnClicked() function, the has reset back to its original value. It looks like I am changing a value in a different scope, but I cannot figure out where.

Updating a single item in angular scope object

久未见 提交于 2019-12-24 17:17:01
问题 I am creating a like function for pictures on an Ionic app. I can return a like count and true or false for if the request was to like or unlike a photo. I have a function on my photos which calls a post action in my controller (the on double tap) <div ng-repeat="update in updates" class="custom-card"> <div ng-show="{{update.image}}" class="image"> <img on-double-tap="likeUpdate({{update.data.id}})" class="full-image" ng-src="https://s3-eu-west-1.amazonaws.com/buildsanctuary/images/{{update

AngularJS - AlertFactory open dialog behavior

巧了我就是萌 提交于 2019-12-24 14:23:25
问题 i'm creating an AlertFactory because ui.bootstrap.dialog doesn't works in my app. So i type follow code: http://jsfiddle.net/Premier/BHqKB/17/ enter code here It works very well if you click on the "Open dialog" button: on screen appear a dialog with my messages. I also register a listener on keydown: listener fires a broadcast event on which is registered a scope related function. This function calls openDialog to show the dialog. In this way angular doesn't interpolates arguments and alert

How can I combine multiple scope models in Angular?

雨燕双飞 提交于 2019-12-24 14:14:26
问题 I have $scope.formTitle = ''; $scope.formDesc = ''; $scope.fields = []; but would like to combine these into one $scope.theForm so I can have one object that would be easily converted into JSON. What's the best way to do this? 回答1: Nothing is stopping you from hosting your properties in a wrapping class . It is actually a recommended approach to use for the properties that are similar in purpose (like form properties for example). // create wrapping class $scope.theForm = {}; // add

Passing AngularJS ng-form object into ng-if?

情到浓时终转凉″ 提交于 2019-12-24 13:29:37
问题 When I click "preview" here the save button in my preview mode is not disabled http://plnkr.co/edit/I3n29LHP2Yotiw8vkW0i I think this is because the form object (testAddForm) is not available in the scope of the ng-if. I know that I should use an object in my controller because it's passed down all the way, but the form object is created by angular and not available in the ng-if. How can I work around that? <!DOCTYPE html> <html ng-app="app"> <head> <script data-require="angular.js@1.2.27"