Questions tagged as 'angularjs'

2
answers

Angular 1 - Using the bindings in the controller - Component

I'm using AngularJs, in creating a component I need to access the bindings in the controller of my component. In html I'm calling the component like this: <component type='tipo' urlid='meuid'></component> I'm using the second...
asked by 16.01.2017 / 12:25
1
answer

ASP.NET MVC with AngularJs and LayoutPage

I'm developing an application using the best of both worlds from Asp.net MVC and AngularJs. I make the bank requisitions with WEBApi which works very well. But now I've added an angular module on the page layout. The page layout ng-app works per...
asked by 13.01.2017 / 18:19
1
answer

How can I set values from my Controller for a form in Ionic / Angular Js?

I have data in my controller that I want to play on my form. How can I play this data for my form? I'll give you an example: My controller data is these variables: $scope.endereco_gps = window.localStorage.getItem("endereco_gps"); var r...
asked by 17.04.2017 / 14:02
1
answer

Return Json - AngularJs

I'm creating an Asp.Net Web.API application and the service return is in Json. So far so good, it turns out that the main object (Companies) is returning an internal object - citiesFiliais (Branches by City) with a Bracket that is not interpr...
asked by 25.10.2016 / 19:57
2
answers

ocLazyLoad to load controllers from a SPA AngularJS

Hello, community! I wonder if it's a good idea to use ocLazyLoad to load the controllers of an application (Single Page Application - SPA) from AngularJS . I'm using UI Router instead of ngRoute . The code I have works perfectly...
asked by 13.11.2016 / 01:13
4
answers

___ ___ erkimt Sharing the variable $ scope from one controller to another with parameters in AngularJS ______ qstntxt ___

I have this:

%pre%

I wanted my second controller to get the $ scope.getIdJobs variable and save it to a variable again. How can I do this?

%pre%

app.js

%pre%     
______ azszpr165042 ___

A simple solution is to have a factory that returns the value that you need (an object for example): JS:

%pre%

HTML:

%pre%

Demo: link

When applications get larger, more complex, and harder to test, you may not want to expose the entire object of a factory in this way, but instead give limited access for example via getters and setters:

%pre%

With this approach controllers consume the service with new values and use $ watch to observe the changes:

%pre%

HTML:

%pre%

Demo: link

    
______ azszpr164875 ___

I'm a beginner too but I'll try to help you by giving two tips:

  • There is %code% that holds information and when loaded can be passed from controllers to controllers, much used for IDs.

  • Another way would be to store this %code% in a service and then use it in other controllers by calling it: %code%

  • ______ azszpr164891 ___

    You can put the products variable in $ rootScope, so you can access it for $ rootScope anywhere. But I advise you to use the ui-router to make the parameters pass, it gets more cohesive and with less chances of you having undesirable variable value substitution problems, or something like that.

    You should set the parameter in your state:

    %pre%

    And it will pass it this way:

    %pre%     
    ______ azszpr165044 ___

    Good,

    In my opinion it is advisable to create a %code% for the date, which will be %code% , where you can encapsulate the date and its %code% . Then just call the %code% you need in the controllers.

    Here's the example in this jsfiddle

    %pre%

    In the controller that accesses %code% you call the %code% method.

    %pre%

    In the second controller, just declare %code% or if necessary you can filter again with a new id.

    %pre%

    In this way, you can clear the %code% , and everything relative to that date can be reached in %code% and %code% easily.

    Or you will have the option of %code% , which also works for what you want.

    About routers, I advise you to take a look at ui-router , a far superior tool in my understanding.

        
    ___

    I have this: $scope.products = []; $http.get('app/components/job/controller/teste.json').success(function (resource) { $scope.products = resource; }); $scope.getIdJobs = function(getIdJobs) { var result = $filter('filter')(...
    asked by 11.11.2016 / 10:55
    1
    answer

    Obtaining a specific property of a JSON object

    I have the following JSON: { "2016": { "mes": { "2": { "dia": { "5": { "-KcENENmSJcZp56clzz5": { "descricao": "teste", "valor": "99" } } }...
    asked by 05.02.2017 / 20:58
    1
    answer

    How to set a variable in the Scope Angular JS

    I have the following dropdown: <select> <option ng-repeat="x in Ruas">{{x.Rua}}</option> </select> I need to get the value selected in the dropdown (x.Rua) and set it to an attribute of another scope called: hom...
    asked by 30.09.2016 / 17:09
    1
    answer

    Extract objects in Ionic

    I'm trying to get the selected data from a Checkbox on Ionic. My View is like this with CheckBox : <ion-view view-title="Comprar Bebidas Adicionais" hide-nav-bar="false"> <div class="bar bar-subheader">...
    asked by 26.08.2016 / 18:33
    3
    answers

    How to render an html that came from a json's answer?

    JSON response: post: { body: "<div>O meu html vem dessa forma</div>" } I would like to know how I can render this% my post.body in my view. Is there any directive that will do this for me ???     
    asked by 05.01.2017 / 17:42