angularjs-scope

AngularJs: Binding ng-model to a list of radio buttons

三世轮回 提交于 2019-12-19 05:23:12
问题 Im trying to bind the selected value in a list of radio buttons to an ng-model I have: <!DOCTYPE html> <html ng-app="testApp"> <head> <script src="./bower_components/angular/angular.min.js"></script> <script src="test.js"></script> </head> <body ng-controller="testController"> <form> <div ng-repeat="option in occurrenceOptions"> <input type="radio" name="occurrence" ng-value="option" ng-model="selectedOccurrence" /><label>{{ option }}</label> </div> </form> <div>The selected value is : {{

Trigger click event on an AngularJS directive in Mocha test suite

假装没事ソ 提交于 2019-12-19 03:19:33
问题 I have a regular angular app with a directive. This directive contains an element with a ng-click="clickFunction()" call. All works well when I click that element. I now need to write a test for this click, making sure that this function was actually run when the element was clicked - this is what I'm having trouble with. Here's a jsfiddle to illustrate my issue: http://jsfiddle.net/miphe/v0ged3vb/ The controller contains a function clickFunction() which should be called on click. The unit

AngularJS - Can I use data binding value depending on ternary operator

我们两清 提交于 2019-12-18 19:49:13
问题 I have an ng-repeat li elements and I want to set a specific value for that li depending on whether a function returns true or false and I don't want to do it in the controller because I have dependency issues where it makes it Minimize or Maximize for ALL li elements but I want it to be for each individual li element. I tried using several things including the following without any luck. I am not sure what I am doing wrong but I would appreciate any input or any other way of doing this.

Using $emit in angular 1.5 component

五迷三道 提交于 2019-12-18 19:00:35
问题 I am using angular 1.5 component and need to call function in parent controller from when $emit in child component. How we can do this? Example: (function (angular) { 'use strict'; controllerName.$inject = []; function controllerName() { var _this = this; function toBeCalledOnEmit() {//some code} var vm = { toBeCalledOnEmit: toBeCalledOnEmit } angular.extend(_this, vm); } angular.module('moduleName', [ ]).component('parentComponenet', { templateUrl: 'templateUrl', controller: 'controllerName'

Angular - ngModel not updating when called inside ngInclude

让人想犯罪 __ 提交于 2019-12-18 18:48:10
问题 First and foremost, the plunker: http://plnkr.co/edit/v1uTz5 This is a working demo of the issue I am running into. I have a ng-include to include a partial. Inside the partial I have an text input with ngModel AND directive. The model updates accordingly inside the include, but any interaction outside the include is ignored. The {{test}} outside the include doesn't update, but the {{test}} inside does. The directive, when called, handles the enter key and calls the correct scope and function

AngularJS: service query returning zero result

∥☆過路亽.° 提交于 2019-12-18 16:57:30
问题 my app.js looks like var app = angular.module('pennytracker', [ '$strap.directives', 'ngCookies', 'categoryServices' ]); app.config(function($routeProvider) { console.log('configuring routes'); $routeProvider .when('/summary', { templateUrl: '../static/partials/summary.html'}) .when('/transactions', { templateUrl: '../static/partials/transaction.html', controller: 'AddTransactionController' }) }); while my app/js/services/categories.js looks like angular.module('categoryServices', [

AngularJS: service query returning zero result

梦想的初衷 提交于 2019-12-18 16:57:15
问题 my app.js looks like var app = angular.module('pennytracker', [ '$strap.directives', 'ngCookies', 'categoryServices' ]); app.config(function($routeProvider) { console.log('configuring routes'); $routeProvider .when('/summary', { templateUrl: '../static/partials/summary.html'}) .when('/transactions', { templateUrl: '../static/partials/transaction.html', controller: 'AddTransactionController' }) }); while my app/js/services/categories.js looks like angular.module('categoryServices', [

AngularJS Expression in Expression

独自空忆成欢 提交于 2019-12-18 16:51:39
问题 Is there a way to have AngularJS evaluate an expression within model data? HTML: <p> {{Txt}} </p> Model: { Txt: "This is some text {{Rest}}" } { Rest: "and this is the rest of it." } The end result would be: This is some text and this is the rest of it . 回答1: You can use the $interpolate service to interpolate the string... function ctrl ($scope, $interpolate) { $scope.Txt = "This is some text {{Rest}}"; $scope.Rest = "and this is the rest of it."; $scope.interpolate = function (value) {

AngularJs $scope doesn't update after a GET request on a factory

徘徊边缘 提交于 2019-12-18 15:36:33
问题 I have been trying AngularJS for a experimental project and I came along with this problem. In my html I want to display a list of items Index.html <h1>Some list</h1> <div ng-controller="datlist"> <div ng-repeat="item in items"> <div>Item description: {{item.description}}</div> <div>Item name: {{item.name}}</div> </div> </div> At first I was using a simple controller to get the information and update the view just using this: controllers.js (original) function datlist($scope,$http){ $http(

AngularJs $scope doesn't update after a GET request on a factory

心已入冬 提交于 2019-12-18 15:36:04
问题 I have been trying AngularJS for a experimental project and I came along with this problem. In my html I want to display a list of items Index.html <h1>Some list</h1> <div ng-controller="datlist"> <div ng-repeat="item in items"> <div>Item description: {{item.description}}</div> <div>Item name: {{item.name}}</div> </div> </div> At first I was using a simple controller to get the information and update the view just using this: controllers.js (original) function datlist($scope,$http){ $http(