angularjs-scope

when I put ng-controller in div instead of body autocomplete stops working

感情迁移 提交于 2019-12-08 04:00:08
问题 I have a textbox with autocomplete capability and after clicking on click me button the text in autocomplete is added as in the table , here is the link that works perfectly fine, var app = angular.module('app', []); app.factory('Service', function() { var typesHash = [ { id :1, name : 'lemon', price : 100, unit : 2.5 }, { id : 2, name : 'meat', price : 200, unit : 3.3 } ]; var localId = 3; availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL",

Refresh of scope after remote change to data

旧城冷巷雨未停 提交于 2019-12-08 03:52:55
问题 In my controller for a mpbile app based on Angular1 is have (for example) the following function: var getItem = function() { // Initialize $scope $scope.url = "(url to get my data)"; $http.get($scope.url).success(function(data) { $scope.itemDetails = data; // get data from json }); }; getItem(); and this works just fine.. with one problem.. it doesnt update. Even if I switch pages and come back, if the scope hasnt changed, it doesnt reflect new data in the scope. So, i built in an $interval

Angularjs custom directive using http promise not binding with template

六眼飞鱼酱① 提交于 2019-12-08 03:33:29
I am new to angularjs and want to add new feature in existing code. But code is not working as expected. I know i am not doing it the right way. Please correct me where is the mistake. I don't know why controller is not used but directive is used in this approach? Here is my custom service and custom directive directive code. Service code: angular.module("quickquiz-builder").service("SettingsService", function ($http, $q) { return { /* Return deffered promise response */ get: function() { var deferred = $q.defer(); $http.get('get.php') .then(function(response){ var config = response.data

Angular $routeProvider: Why does CRUD new route not work?

别等时光非礼了梦想. 提交于 2019-12-08 03:30:57
问题 I'm building an Angular app with RESTful CRUD actions. Almost everything is working except for the /users/new route ~ it displays the show view instead of new view specified in $routeProvider. However, '/new' does work. I'm not getting any feedback in the js console. Any ideas or examples I should read? App.config [ '$routeProvider' '$locationProvider' ($routeProvider, $locationProvider, config) -> $routeProvider .when('/', templateUrl: '/partials/home.html' ).when('/users', templateUrl:

Bind an externally loaded DOM element to Angular's scope

倖福魔咒の 提交于 2019-12-08 03:30:25
问题 I'm using Google Maps within an Angular app. As per Google Maps's API, I pass a string to a google.maps function containing HTML, and the library displays it on the map as an InfoView. I'm adding a button to this view, and I want this view to be bound to a controller in my Angular app, however, even if I pass <div ng-controller="MyController">...</div> , when the Maps library attaches it to the DOM, Angular is not notified. How can I force the compilation of this element (over which I have

AngularJS - directive scope not setting ng-class on element

一个人想着一个人 提交于 2019-12-08 03:11:25
Plunker I have a table of data: <table class="table table-hover" ng-class="dndElemClass" drag-and-drop> ... </table> My goal is to give the table a drop shadow by assigning $scope.dndElemClass = 'on-drag-enter' on the element's ondragenter event listener: .on-drag-enter { -webkit-box-shadow: -3px 3px 5px 3px #ccc; ... } The onDragEnter directive is as follows: directive('dragAndDrop', function() { return { restrict: 'A', controller: function($scope) { $scope.dndElemClass = ''; }, link: function($scope, elem, attr) { $scope.$watch('currentFolder.canUpload', function(newValue, oldValue) { if

Pass scope to Service on AngularJS

只愿长相守 提交于 2019-12-08 02:43:46
问题 I'm pretty new to AngularJS, I want to pass the scope to a service so I can perform a tag search based on the scope.value. <div data-ng-app="instaSearch" data-ng-controller="search"> <div> <input type="text" value={{value}} data-ng-model='value'/> </div> <p data-ng-hide="value">type a tag</p> <p data-ng-show="value">...looking for {{value}}</p> <ul> <li data-ng-repeat="r in results"> <a> <img ng-src="{{r.images.thumbnail.url}}" alt="" /> </a> </li> </ul> </div> Here is the JS var app =

Angular scope is shared for all modules and controllers

▼魔方 西西 提交于 2019-12-08 01:57:26
问题 I have a single page application, which has a root module with about 5 seperate smaller modules. var rootModule = angular.module('root', ["firstModule", "secondModule", "thirdModule"]) Each module has directives and controllers. Today I discovered that I can access other module and controller scope from all other modules and controllers. So for example this controller: thirdModule.controller('ThirdController', ['$scope', function ($scope) { alert($scope.title); } And in this controller I

AngularJS view not reflecting $scope.model, though data is being set

怎甘沉沦 提交于 2019-12-08 01:08:20
问题 Thank you so much for reading my question :) Aim: I want to persist a logged-in user's name and photo if they open a new tab or refresh. When originally authenticating (calling attempt.login on the form submit), the view updates fine (like so:) userController.js.coffee: $scope.attemptLogin = -> $scope.showLoginForm = false $http.post(apiURL + "/login" email: $scope.credentials.email password: $scope.credentials.password ).success (data) -> if data.error console.log "error: " + data.error else

AngularJS : How to transclude and have both isolate scope and parent scope?

倖福魔咒の 提交于 2019-12-07 23:59:57
问题 I have a pattern wherein many item types are "editable". This means that I have lots of templates (one for each editable item type) that expect to have unique fields, but common functions (edit, save, cancel edit, delete, etc.). These common functions lead to lots of repetition on controllers: save , edit , cancel , etc., and very repetitive error-handling. One way I looked at of dealing with this was to have each controller "decorate" itself (using a service), but it got messy as well. I