w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
Access model from controller. Angular.js
Angular does not process the value attribute. If you want to initialize the model value to something in the input, you need to use ng-init, f.ex. <input ng-model="foo" ng-init="foo = 3">

Categories : Javascript

How to access $viewValue from controller in Angular
You can put the initialization code in the directive and pass in the the data you need: <input my-cell ng-class="'lib_name inline_div'" type='text' value="{{ lw.library.name }}" > Then the directive changes to something like this: angular.module('Demo').directive("myCell", function(){ return { function(scope, element, attrs){} scope.row = row; scope.column = column; scope.CellStore.addCell(scope.lane.lane, row, column, attrs.value); }; }) ; Since I can't see the rest of your app code, you may need to change some of the variable names to get it to work, but the basic premise is to just use the link function of the directive to run your initialization. Also, in the directive you have access to the inhe

Categories : Angularjs

Angular access controller scope from nested directive
Use <div ng-transclude></div> instead of <ng-transclude></ng-transclude> in the template of modal directive.

Categories : Angularjs

Angular JS/Karma Unit Testing with Angular UI-Router
At first glance I would say it looks like the $stateProvider is telling you you need to put an empty state in there. Add this to the list of states. state( '', { ... } )

Categories : Unit Testing

Preserve state with Angular UI-Router
I have found Angular-Multi-View to be a godsend for this scenario. It lets you preserve state in one view while other views are handling the route. It also lets multiple views handle the same route. You can do this with UI-Router but you'll need to nest the views which IMHO can get ugly.

Categories : Angularjs

Angular.js UI-Router Children Scope
You will either have to: Add an additional abstract state at the top level that has a template of '<ui-view/> and also a controller with all the scope items you need. So you'd essentially be moving the important shared scope items be a part of this top level state instead of networks.details. Then set networks.details.show to populate this new state's view, e.g. "@newstate". Use a shared service to talk and maintain 'state' between the two state controllers. This may be the cleaner solution. Inject a service (e.g. "NetworksDetailsShowState") into both controllers and proxy the service's properties onto scope properties in both controllers and then change the service at will.

Categories : Javascript

Angular JS ui-router on Internet Explorer 8
Can you try building off of master? There was a pull request merged just after the last release (https://github.com/angular-ui/ui-router/pull/392) that resolved some IE8 issues. Everything else should work fine AFAIK.

Categories : Angularjs

With angular.js using ui-router, how to only reload one view?
Based on the voted answer of that question angularjs ui-router - how to build master state which is global across app app.config(['$stateProvider', function ($stateProvider) { $stateProvider .state('todo', { abstract: true, views: { "navPanel": { templateUrl: "./navPanel.html", controller: 'PanelController' } } }) .state('todo/:item', { url: "/todo/:item", views: { "ContentView@": { templateUrl: "./content.html", controller: 'ContentController' } } }) }]);

Categories : Angularjs

Angular ui-router get asynchronous data with resolve
I think your controller function needs $stateParams parameter from which you can get your propertyId. Then you can use $q parameter and create promise to set $scope.property with something like this: var deferred = $q.defer(); gapi.client.realestate.get(propertyId).execute(function(resp) { deferred.resolve(resp); }); $scope.property=deferred.promise; Here is description of using promises for handling async calls.

Categories : Angularjs

Yeoman/Angular/Coffee .when() router won't route - cannot GET
Html5 mode is not only about Javascript, it also needs the server to support it. When you try /youtube it first goes to the server, if the server can't manage it, you should render the angular application so the router can catch the route and show what you need. I am not sure if Yeoman supports html5 mode to be honest. You could try linemanjs which is like Yeoman and it supports html5 mode. If you want to use Yeoman, google for html5 mode for yeoman or use hashbang :)

Categories : Javascript

How can I use angular-ui/ui-router to dynamically populate a sub view?
You would create a child state for var homeOverview = { name: 'home.overview', parent: 'home', url: '/overview', views: { 'grid@': { templateUrl: '/Content/app/home/partials/overview.html', controller: 'HomeOverviewController', } } } like this var homeOverViewItem={ name: 'home.overview.item', parent: 'home.overview', url: '/:id', views: { 'grid@': { templateUrl: '/Content/app/home/partials/overviewItem.html', controller: 'HomeOverviewItemController', } } } In the home view overview.html at some place you would define the ui-view tag which would get template html inserted from overviewItem.html. See some samples here https://github.com/angular-ui/ui-router/wiki/Nes

Categories : Angularjs

Is there a cleaner way to use angular ui nested routes with ui-router?
Naming your views is optional, especially if you only have one I recommend using an unnamed view. You should probably drive deeper into the UI router wiki and guide. Also the projects main readme file has just been updated. It now shows a quick start example for nested states, which is actually a much more common used feature. Multiple named views really aren't necessary in most cases. Essentially you'll shorten each state declaration to: .state('route3', { url: "/route3" templateUrl: "partials/bauer.html" })

Categories : Javascript

Angular UI Router - Views in an Inherited State
According to the ui-router documentation, when the application is in a particular state—when a state is "active"—all of its ancestor states are implicitly active as well. So, for example, when the "contacts.list" state is active, the "contacts" state is implicitly active as well, because it's the parent state to "contacts.list". Child states will load their templates into their parent's ui-view. I'd reccomend looking over the section of their documentation entitled Nested States & Views to gain a fuller understanding of how to do this. In the code you have provided us here, the parent state of the search template is home, while .state('header.search', { templateUrl: "views/search.html", controller: "SearchCtrl" }) implies that the parent state of the search template sho

Categories : Javascript

Angular UI-Router testing scope inheritance
Scope inheritance is a feature of Angular. I therefore think that it is not necessary to test in my tests. My workaround is to test that the AccountCtrl works and then just put the values in the other tests: it("should set scope when account Ctrl loaded", inject(['$controller', 'security', function($controller, security){ // Add your behavior testing code here var $scope = $rootScope.$new(); var user = { first: 'First', last: 'Last', email: 'testuser@test.com', gender:'male', birthday:'password'}; security.currentUser = user; $controller('AccountCtrl', { $scope: $scope}); $rootScope.$digest(); // verify the initial setup expect($scope.user).toEqual(user); expect($scope.account).toEqual(user); }])); Then in the other tests I manually populate the values: it('should

Categories : Angularjs

Deep-linking fails to set state in Angular-UI ui-router
I added <base href="/"> in the <head> section of my HTML, and that solved the problem. To see the modified (and corrected) version, go here: http://gist2.perlmodules.net:8080/a/funny This bug and it's solution is described here: https://github.com/angular-ui/ui-router/issues/200#issuecomment-20932129 ...and in the link at the bottom of that page.

Categories : Angularjs

Confused in how to implement tab based app with angular ui-router (like gmail)
I was looking for the same info, does the following example help you?http://plnkr.co/edit/gMsKK9l7J0B8vZIMIVfD?p=preview (Not my coding.) Edit: I've found more useful data. https://github.com/angular-ui/ui-router/wiki/Multiple-Named-Views In my code, I have set it up like this: .state('surveys.list', { url: '/list', templateUrl: "survey/surveys_overview.tpl.html", controller: 'SurveyOverview' }) .state('surveys.create', { abstract: true, templateUrl: "survey/survey.create.tpl.html", controller: 'SurveyManageController' }) .state('surveys.create.views', { url: '/create', views: { 'details': { templateUrl: "survey/sur

Categories : Angularjs

angular-ui-router blank page with index.html in URL
Add url:'/' to the base abstract view. .state('layout', { abstract : true, url:'/', views : { "headerView" : { templateUrl : 'partials/header.html', controller : 'LoginController' }, "navigationView" : { templateUrl : 'partials/navigation.html', controller : 'NavigationController' } } })

Categories : Angularjs

Resolve on Angular UI Router appStates not Delivering Scope Data
What I ended up doing was returning a promise in my curriculumHash service. Then putting a resolve into appStates.js so that the controller won't start up til the promise is resolved. Like so: .state('dashboard.create', { // parent: 'dashboard', url: '/create', views: { '': { templateUrl: "/app/partials/create.html", resolve:{ 'curriculumHashPromise':function(curriculumHash){ return curriculumHash.promise; } }, controller: ['$rootScope', function(rootScope){ //I will have access to all curriculumHash methods as well as dashBoard }], } }, I referred to this question here to find my answer. Let me know if anyone needs more details, but the reference is incredibly useful.

Categories : Angularjs

How to get angular ui-router's ui-sref to work, when inside a directive's template?
Ok, I've solved my problem. It appears that I was confusing states with urls. A link with ui-sref will trigger state change to a given state, and will optionally change/generate the url, if one is defined in the state. Also states themselves do not have parameters, but urls do. Here's my understanding of a state: A state in ui-router refers to a state of the website defined in a given html template. This template can have defined ui-views, i.e. place-holders (that can be named) that will be populated by other states. Any state can target one or more ui-views inside other states' template with respective html templates - i.e. they can put the content of those templates into ui-views of other states' templates. Every state can have an associated url, which links the url in the browser with

Categories : Javascript

angular-ui / ui-router nested states not inheriting custom data
Inherited custom data just landed and is not part of the stable release. You'll have to build ui-router manually. https://github.com/angular-ui/ui-router/blob/master/README.md#developing

Categories : Javascript

Ember.js - Propagate event up the controller/router chain
One way to achieve this could be: App.SampleController = Ember.ObjectController.extend({ needs: 'application', myEvent: function(obj) { this.set('aVariable', true); this.get('controllers.application').send('myEvent'); } }); Working demo. Hope it helps.

Categories : Javascript

angular.bootstrap() - bootstrapping an angular app without the need for ng-app or ng-controller
Update: Missed the part of the title that said you wanted to avoid ng-controller. If you need to add behavior defined in a controller then the easiest way is to just use the ng-controller directive. You can get away with what I wrote below without exposing any angular specifics on your clients. If it's an absolute that you not use ng-controller but still want controller behavior, you'll probably need to dive into the Controller Factory code and see how you can create and attach the scope to your controller method. This seems like more complexity than its worth. Original Post: You're bootstrapping the app but you're using a controller that hasn't been added to the HTML elements you're creating. I'm assuming you're going to inject some HTML, so you should be able to decorate your main DI

Categories : Javascript

How to add attributes to Controller or customize a Controller in Angular
I think this approach is fine, but if you wanted to refactor your grids into their own directives, you would have access to the DOM element through the 'element' variable in the link function. If you needed to do something based on the ng-click directive, you can watch a scope variable in the directive or listen to a broadcast on the root scope and take an action in the directive itself. Something like this: <div id="dataGrid1" my-app-directive="fireACtion" ng-click="fireAction = !fireAction" /> Then in your directive just watch attrs.myAppDirective (which is fireAction) scope.$watch(attrs.myAppDirective , function (newVal, oldVal) { //When the value changes, this will run } This will encapsulate all this logic inside the directive and you will also inherit the controlle

Categories : Angularjs

communicate between angular controller and route controller
What I've done is: var app = angular.module('myApp', ['controllers']) .config(['$routeProvider', function ($routeProvider) { $routeProvider. when('/', { controller: 'mainCtrl', templateUrl: 'index.html' }). otherwise({ redirectTo: '/' }); }]); var controllers = angular.module('controllers', []); Then: // separate file controllers.controller('mainCtrl', ['$scope' function ($scope) { // do stuff with $scope } ]); You can probably do app.controller('mainCtrl' ... instead and save a controllers variable. I just happened to get this working on my site this way. Also, make sure you have an ng-app of myApp enclosing an element with ng-view (for routing to work).

Categories : Angularjs

How to access the password protected Router Page from Python?
Basically you need to set the cookie which maintains the session, most probably. Access the page via a browser(Firefox) enter the login pass when prompted to do so. Press Ctrl-Shift-k, and reload the page and click on any of the most recent GET requests, you'll get a window showing the GET request details. Note the Request Headers and set the cookie accordingly. The key-value which would be the most useful is Authorization.

Categories : Python

How to access methods from a sub controller without - from the beginning - knowing which sub controller?
This might work: class WebshopsController < InheritedResources::Base custom_actions :resource => :reset From the inherited_resources docs: Since version 1.2, Inherited Resources allows you to define custom actions in controller: class ButtonsController < InheritedResources::Base custom_actions :resource => :delete, :collection => :search end This code creates delete and search actions in controller (they behaves like show and index actions accordingly). Also, it will produce delete_resource_{path,url} and search_resources_{path,url} url helpers.

Categories : Ruby On Rails

Ember how to access a child controller from a parent controller
In your ArrayController ensure you are setting the itemController: Schedule.PeopleController = Ember.ArrayController.extend({ itemController: 'Person', editCounter: function () { return this.filterProperty('isEditing', true).get('length'); }.property('@each.isEditing') }); See http://jsbin.com/eyegoz/4/edit

Categories : Javascript

Access $stateParams of new state in service called from resolve function with UI Router
You can't inject the the incoming parameters into the service itself, but you can pass them to a function in the service (or you could also assign them to a property in the service). this plunker shows how to pass them to a function, which in turns stores them to a property in the service. Using a "dummy" property shouldn't hurt, but it is a bit ugly. :) It might make more sense to pass the parameters to the controller as a resolve property and then hand them out to a service from the controller constructor... that's what I'd do.

Categories : Javascript

Fat Free router blocks Backbone router, how/when does Backbone router.js work?
If you are not using pushState, then the backbones routes are easy to differentiate from the server routes: /route1 /route2 /route1#route/a /route1#route/b The part before the hash is the one transmitted to the server (F3 routes). The part after the hash corresponds to the backbone routes. //F3 routing $f3->route('GET /route1',…) $f3->route('GET /route2',…) //Backbone routing routes: { "route/a": "routeA", "route/b": "routeB", } Note that the Backbone router doesn't generate any HTTP request to the server (unless you specifically define it of course). What generates automatically HTTP requests is the Backbone model. A backbone model is mapped to a server resource using urlRoot. The methods fetch(), save() and destroy() are then mapped respectively to the GET, PUT and

Categories : Backbone Js

What's the purpose of setting $rootScope.$state = $state; with angular-ui ui-router?
I don't think this is standard code. The only reason i see these being added to you rootScope it to facilitate binding within the html view everywhere. Else if you want to bind to some property of either $state or $stateParams you would have to inject the $tate and $stateParams service into the controller. Ideally this should be injected into controllers that require this service. If you remove it any html binding dependent on it would fail. Search html views for bindings with name $state and $stateParams and you would find where they are used.

Categories : Angularjs

Meteorite router package installation - Uncaught 'error' event on 'mrt add router'
Node 0.10.9 has a couple of issues. I'm not sure it'll help but try mrt add router --repoPort=80 as suggested here : https://github.com/oortcloud/meteorite/issues/135

Categories : Javascript

How to access controller from other controller in Laravel?
Controllers are mapped to actions (one route perform one action). You can call a controller by calling his route. Because getting images, and saving them are part of the same action (ie: same route), I recommend you to move that code to a library or helper (or why not a model, because you are retrieving and saving data) Anyway, I don't get the reason why you are doing that in controllers. Controllers usually perform operations between models and the views. Fetching data from a webservice belong more to models than to controllers. In fact, I really recommend you to move that code to a library to be reusable later. Your controller must only have the responsibility of calling the library's read method to read the image, then saving it locally using a model.

Categories : PHP

KnockOut JS - applying a new binding. Error - Message: ReferenceError: 'router' is undefined; Bindings value: css: { active: router.isNavigating }
Before you execute the problematic code, the Composition lifecycle of Durandal has bound the the shell.jsand subsequently the ViewModel agency.js with the UI. Meanwhile in the addContact function, at the last line you basically change the whole binding applied to the view: ko.applyBindings(objAgency); So your whole UI is now bound to this objAgency which I guess does not contain a router instance as the errors is pointing : ReferenceError: 'router' is undefined; This error comes probably from the binding of the shell because is no longer bound to the UI since your code applied new bindings. SOLUTION: The applyBindings is managed by Durandal in the composition process. If you want to modify some properties of the ViewModel there's no need to update the bindings. I don't know if

Categories : Javascript

How to test Meteor router or Iron router with laika
I had the same problem. I needed to navigate to some page before running my tests. I'm using iron router as well. I figured you can't just execute Router.go('foo') and that's it. You need to wait until the actual routing took place. Fortunately the router exposes a method Router.current() which is a reactive data source that will change as soon as your page is ready. So, in order to navigate to a specific route before running my tests, I firstly run the following code block: // route to /some/path client.evalSync(function() { // react on route change Deps.autorun(function() { if (Router.current().path == '/some/path') { emit('return'); this.stop(); } }); Router.go('/some/path'); }); Since this is within an evalSync()everything that

Categories : Meteor

Set a Variable in one View Controller and Access it in another View Controller based on a Button Pressed
A better approach may be to create a class which is the data model for your common data. In this case it's just the float value for your timer. Create an instance of the model class, and then add a property for the object in each of your view controller classes. When you instantiate the view controller, set it's property to point to the model object. Hopefully that makes some sense?

Categories : IOS

Access text from UITextField in modal View Controller from Home View Controller
When I ran into this problem, I chose the singleton approach and it works.

Categories : IOS

Reinitialize an Angular.js controller
Just after asking, I finally found one way to solve this using $route.reload(). myapp.Controller('SampleController', function($location, $route) { $scope.navTo = function(url) { if ($location.path() === url) { $route.reload(); } else { $location.path(url); } } }); I'm still thinking, that there must be some more elegant solution, but this definitely works for me.

Categories : Javascript

Angular value not being set in controller, but can be set in view
You can do that: HTML <div ng-controller="MainCtrl"> <button ng-click="query.Active=true"></button> </div> OR HTML <div ng-controller="MainCtrl"> <button ng-click="active()"></button> </div> JS function MainCtrl($scope) { $scope.active = function() { $scope.query.Active = true; } }

Categories : Angularjs

How to use this angular factory in controller?
Are you sure your dependency is being injected into your controller? var MyController = function($scope, cordovaReady) { ... } MyController.$inject = ['$scope', 'cordovaReady'];

Categories : Javascript

How do I add a controller to a module in Angular JS
Based on what you have shared, the the controller should be created on admin module such as var adminModule=angular.module('admin'); // This syntax get the module adminModule.controller('AdminContentController', ['$scope', 'entityService', 'gridService', 'gridSelectService', 'localStorageService', function ($scope, entityService, gridService, gridSelectService, localStorageService) { $scope.entityType = 'Content'; You could also define the controller in continuation of your admin module declaration.

Categories : Angularjs



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.