angularjs-scope

watch changes on JSON object properties

筅森魡賤 提交于 2019-12-11 18:24:07
问题 I'm trying to implement a directive for typing money values. var myApp = angular.module('myApp', []); var ctrl = function($scope) { $scope.amount = '0.00'; $scope.values = { amount: 0.00 }; }; myApp.directive('currency', function($filter) { return { restrict: "A", require: "ngModel", scope: { separator: "=", fractionSize: "=", ngModel: "=" }, link: function(scope, element, attrs) { if (typeof attrs.separator === 'undefined' || attrs.separator === 'point') { scope.separator = "."; } else {

Angular: Updating $scope with new data causes old data to remain when using ng-repeat

人走茶凉 提交于 2019-12-11 17:35:25
问题 I'm having a strange issue where I replace the values in $rootScope.data.vehicles with new data but the old data points on my view remain for about one second alongside the new data. For instance, right after I replace the $rootScope.data.vehicles array with a new array my view will display the 3 new values first followed by the 3 old values. View is using ng-repeat on $rootScope.data.vehicles to display tiles. About one second later the 3 old values are no longer displayed in the view. Each

How to route using ngRoute (with Demo)

心不动则不痛 提交于 2019-12-11 17:33:21
问题 My code starts from here <!DOCTYPE html> <html> <head> <title>Routing</title> </head> <body ng-app="myApp"> <a href="#/login">Login</a> <a href="#/register">Register</a> <div ng-view></div> </body> <script src="angular-min.js" type="text/javascript"></script> <script src="angular-route.js" type="text/javascript"></script> <script> var app = angular.module("myApp", ["ngRoute"]); app.config(function($routeProvider) { $routeProvider .when("/login", { templateUrl : "login.html" }) .when("

Angular view template content updates only on mouse over

旧城冷巷雨未停 提交于 2019-12-11 16:41:57
问题 I have a strange behavior using an Angular template with a controller . A special view content often updates on mouse over only. I have setup a few jsFiddles but cannot reproduce the problem. So it is obviously a mistake in my source code. The only special thing I see here is that I use a $scope method to format and display HTML content. {{order.total()}} € It is weird that it work sometimes. All other HTML parts are updating as expected. Any idea what could be wrong? $scope.order = { _total

Use config.json file's parameters in app

倾然丶 夕夏残阳落幕 提交于 2019-12-11 16:31:28
问题 We are using google map api and we have a key. We have codede this key in one of our module file. We want to use this key in config.json file so that it should be secure and when we push our changes to git, it should not be available as we dont push our config.json file on git. I don't have any idea about this. mobile-content.module.ts @NgModule({ imports: [ AgmCoreModule.forRoot({ apiKey: 'GOOGLE-API KEY', libraries: ['places'] }), hip-config.json googleMapsApiKey: "GOOGLE-API KEY" <--- want

Directive's isolated scope variables are undefined if it is wrapped in a directive which has in its template ng-if and tranclusion enabled

扶醉桌前 提交于 2019-12-11 16:26:36
问题 I am facing is an issue which is demonstrated in the following example: http://jsfiddle.net/nanmark/xM92P/ <div ng-controller="DemoCtrl"> Hello, {{name}}! <div my-wrapper-directive> <div my-nested-directive nested-data="nameForNestedDirective"></div> </div> </div> var myApp = angular.module('myApp', []); myApp.controller('DemoCtrl',['$scope', function($scope){ $scope.name = 'nadia'; $scope.nameForNestedDirective = 'eirini'; }]) .directive('myWrapperDirective', function(){ return { restrict:

AngularJS : Custom directive scope not being initialized properly when used with ng-repeat

懵懂的女人 提交于 2019-12-11 14:54:02
问题 I have a problem with passing object information to my custom directive, which has an isolate scope. I have boiled my problem down to this simple plnkr to demonstrate the wall I am hitting: http://plnkr.co/edit/oqRa5pU9kqvOLrMWQx1u Am I just using ng-repeat and directives incorrectly? Again, my goal is to pass the object information from the ng-repeat loop into my directive which will have its own scope. HTML <body ng-controller="MainCtrl"> <ul> <li ng-repeat="i in items", my-directive="i">

AngularJS edit scope with same name from another method

試著忘記壹切 提交于 2019-12-11 14:45:04
问题 I would like to update some value in scope with same name in another method of same class. Problem is that update method is not working if i'm trying to update scope named gridData . Should i use scope apply or something Simillar in Angular? Here is my code: orders.controller('OrdersCtrl', function ($scope, $http, $rootScope, $location, $notification, $routeParams, ApiService) { $scope.gridData = {}; $scope.initGrid = function () { $scope.gridData = new kendo.data.ObservableArray([ { artist:

Angular Share Variable betwen $http.get and controller [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-11 13:54:39
问题 This question already has answers here : How do I return the response from an asynchronous call? (36 answers) Closed 4 years ago . I can't pass the content of one variable inside $http.get() to outside of this method... it's always undefined . I tested with $rootScope , but it didn't work. controller('myControl', function ($scope, $http) { var content; $http.get('../Json/data.json').success(function (data, content) { content = data; }).error(function (data, status, headers, config) { $scope

Use ng-model in nested Angularjs controller

孤街醉人 提交于 2019-12-11 12:54:39
问题 I have two nested controller in angularjs, and want to use ng-model from outer in inner controller. Suppose this <div ng-controller='outController'> // data.Name : from outer controller <div ng-controller='innerController'> <input type="text" ng-model='name' ng-init='name=data.Name'> {{data.Name}} // display this scope value </div> </div> data.Name value display in html page but not bind to name ng-model. How to bind this value to inner ng-model? 回答1: You should follow dot rule in this case,