Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
Are you searching for a mounted element within a tree, or just a class that you can use somewhere. If its the latter React doesn't actually have a registry of classes, but you could easily create an object that'll hold class references yourself.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

The Wizard of Poz posted:

Yep, that's what I figured was happening but wasn't sure how to fix it (very new to React). Thanks so much!

On a related note, are there any Visual Studio users here who develop with React? A cursory Google doesn't locate any JSX syntax highlighting solution for Visual Studio, how do you guys handle this? Do you use a separate tool (not ideal, but I can handle it if need be)?

Also, how do you guys handle rendering your JSX files to JS with Visual Studio? Or, again, do you do this with an external tool?

I don't use Visual Studio (I use a Jetbrains IDE), but I just run a transformer in a terminal window set to watch mode so it just recompiles on the fly.

Specifically, on my current project i'm using Browserify with watchify for packaging everything into a single js file. So I run this in a terminal:
code:
watchify -v --debug -t [ reactify --es6 --target es5 ] js/main.js -o js/bundle.js
And then just do my poo poo.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Maluco Marinero posted:

Are you searching for a mounted element within a tree, or just a class that you can use somewhere. If its the latter React doesn't actually have a registry of classes, but you could easily create an object that'll hold class references yourself.

Also, it makes me a little nervous that you're wanting to do this at all. Maybe you're using React a little...wrong-ish?

wwb
Aug 17, 2004

The Wizard of Poz posted:

Yep, that's what I figured was happening but wasn't sure how to fix it (very new to React). Thanks so much!

On a related note, are there any Visual Studio users here who develop with React? A cursory Google doesn't locate any JSX syntax highlighting solution for Visual Studio, how do you guys handle this? Do you use a separate tool (not ideal, but I can handle it if need be)?

Also, how do you guys handle rendering your JSX files to JS with Visual Studio? Or, again, do you do this with an external tool?

There aren't though it is officially on the web essentials team's and resharper's radar from what I found out -- meaning a good solution will be in the offing in the forseeable.

Not sure what the guys doing the react work are using these days, I'll check.

Hanpan
Dec 5, 2004

Thermopyle posted:

Also, it makes me a little nervous that you're wanting to do this at all. Maybe you're using React a little...wrong-ish?

I have several different 'panels' that I am showing on a dashboard, and the type of panel is dictated by data coming from the backend. I guess what I should do is introduce a controller that keeps a reference of all my React views and instantiates them accordingly. I just didn't want to duplicate logic if it was already part of React.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
To everyone learning React: your knowledge now has more use cases. Facebook announced React Native which lets one build native (not DOM-based) mobile apps in React: https://m.youtube.com/watch?v=7rDsRXj9-cU

Lumpy fucked around with this message at 13:21 on Jan 30, 2015

Huragok
Sep 14, 2011

Hanpan posted:

I have several different 'panels' that I am showing on a dashboard, and the type of panel is dictated by data coming from the backend. I guess what I should do is introduce a controller that keeps a reference of all my React views and instantiates them accordingly. I just didn't want to duplicate logic if it was already part of React.

Have a look at Fluxxor + React Router.

Raskolnikov2089
Nov 3, 2006

Schizzy to the matic
X-posting this but:

Anyone here ever go to a code bootcamp, or hire/have experience working with someone who did? I'm curious how it all worked out.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Hanpan posted:

I have several different 'panels' that I am showing on a dashboard, and the type of panel is dictated by data coming from the backend. I guess what I should do is introduce a controller that keeps a reference of all my React views and instantiates them accordingly. I just didn't want to duplicate logic if it was already part of React.

If I understand your problem what I'd do is have your component that contains your panels.In your render method have code to determine the type of panel components to display and then display them.

Something like:

JavaScript code:
render: function () {
  var panels = [];
  
  this.props.panelData.forEach(function(elem) {
    if (elem.whatever == something) {
      panels.push(<OneTypeOfPanel data={elem}/>)
    }  else if (elem.whatever == somethingelse) {
      panels.push(<AnotherTypeOfPanel data={elem}/>)
    }
  }) 
    
  return (
      <div>
        {panels}
      </div>
  )
}

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal
I think this is the right place for this.

It seems like a lot of modern JS libraries are pretty terrible at explaining both what they do, and once you figure that out, how to do it.

Anyway I'm trying to learn how to use requirejs for easy dependency management and DRY templating as far as script loading goes, for what I'm hoping is a small, easy project. Am I doing this right?

index.html
<script data-main="js/main" src="js/vendor/require.js"></script>

js/main.js
require(["vendor/modernizr-2.6.2.min"], function(mordernizr) {
});


js/vendor
-- modernizr-2.6.2.min.js

Can I do the same for Google Analytics? Angular?

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
I just ran into this: http://stackoverflow.com/questions/26687039/having-trouble-unit-testing-a-helper-from-an-addon-project

I.e. the generated unit test for a handlebars helper simply does not work.

Except the solution that dude found, accessing the _rawFunction property, does not work, because of course it doesn't (_rawFunction is undefined). This is Ember and it worked 2 months ago, why would it work anymore?

"// Replace this with your real tests." is not a very helpful comment when, afaik, there is no documentation on how you're supposed to test helpers.

I have to say, I'm not really loving Ember

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope
Okay, the "ember generate" command is pretty useful for figuring out what ember expects your project structure to be. In this case ember generate helper hello generates this helper file:

JavaScript code:
import Ember from 'ember';

export function hello(input) {
  return input;
};

export default Ember.Handlebars.makeBoundHelper(hello);
Whereas our code only has export default Ember.Handlebars.makeBoundHelper(function(value) {, without ever exporting the bare function. :cripes:

TildeATH
Oct 21, 2010

by Lowtax
I've got an ember CLI project and I want to create a select with options dynamically outside of ember-land and use Select2 to turn it into a Select2 thing. I added select2.min.js to my brocfile and since ember already has jquery baked in, I thought I could do $("my-select-element").select2() somewhere in the bowels of some javascript somewhere and be fine.

But it looks like the select2 function isn't being registered and comes back undefined. Anyone got any ideas why and suggestions on how to make this work? I realize I'm operating outside what Ember wants me to do, so I know the answer may be, "Nuh uh".

Kobayashi
Aug 13, 2004

by Nyc_Tattoo

TildeATH posted:

I've got an ember CLI project and I want to create a select with options dynamically outside of ember-land and use Select2 to turn it into a Select2 thing. I added select2.min.js to my brocfile and since ember already has jquery baked in, I thought I could do $("my-select-element").select2() somewhere in the bowels of some javascript somewhere and be fine.

But it looks like the select2 function isn't being registered and comes back undefined. Anyone got any ideas why and suggestions on how to make this work? I realize I'm operating outside what Ember wants me to do, so I know the answer may be, "Nuh uh".

Are you doing app.import(...) in the brocfile? I include things like D3 and moment and they "just work" in views when I need them without any extra boilerplate so seems like what you are trying to do should be fine.

TildeATH
Oct 21, 2010

by Lowtax

Kobayashi posted:

Are you doing app.import(...) in the brocfile? I include things like D3 and moment and they "just work" in views when I need them without any extra boilerplate so seems like what you are trying to do should be fine.

Yup:

code:
app.import('vendor/select2.min.js');
And I've been doing the same with various other libs like D3 and it works fine. I feel like maybe it's that select2 extends jquery, so I have to do something special because jquery is baked in? But I haven't got a clue. Also, is there some way to see when a brocfile import fails, because that seems very opaque to me.

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION
I kind of hinted toward this in a previous post, but I'm wondering what people's overall workflow looks like for those of you that use tools like Visual Studio. I'm a full stack developer so I tend to be working on a lot of .NET C# stuff as well as the frontend, meaning I'd like to do as much as I can within the same IDE. Specifically I'm referring to things like RequireJS, how do you guys manage the compiling of the modules into a bundled JS file? How do you compile your JSX files? Someone mentioned having a watcher running (this is what I currently use with npm: watchify + browserify) but I was wondering if there's something that is more integrated with Visual Studio?

On another note, I'm reading this guide: http://fluxxor.com/documentation/flux-mixin.html which contains this tidbit:

quote:

Ideally, an instance of Flux on the context of a child component should only be used to dispatch actions, and not to read data from the stores—read data from the stores at the top-level component and pass the data through props as necessary.

I want to understand all these different best practices and I'm wondering if there's a nice guide somewhere that will go through the process of writing a basic SPA (yet, more complex than a todo list) so I can get an idea of some of the essential libraries that are out there and how best to structure an app written with React. I guess what I mean is that I'm looking for something a little more high-level than "this is how you build a React component", some more like "this is how you build a React application".

Knyteguy
Jul 6, 2005

YES to love
NO to shirts


Toilet Rascal

The Wizard of Poz posted:

I kind of hinted toward this in a previous post, but I'm wondering what people's overall workflow looks like for those of you that use tools like Visual Studio. I'm a full stack developer so I tend to be working on a lot of .NET C# stuff as well as the frontend, meaning I'd like to do as much as I can within the same IDE. Specifically I'm referring to things like RequireJS, how do you guys manage the compiling of the modules into a bundled JS file? How do you compile your JSX files? Someone mentioned having a watcher running (this is what I currently use with npm: watchify + browserify) but I was wondering if there's something that is more integrated with Visual Studio?

I'm not entirely sure if this is what you're looking for, but Web Essentials is great. If you don't have it yet it's pretty nice for bundling. So you can have all your separate files unminified in VS, and just point your includes/header references to the generated bundle file. If any actual compiling is necessary for modules or something I've just written plugins that run command line stuff first, which I'd imagine you could get to to work with the bundle if you needed to (you can configure when the bundle is generated).

e: took me a minute to get that phrasing how I wanted it.

Knyteguy fucked around with this message at 17:24 on Feb 3, 2015

putin is a cunt
Apr 5, 2007

BOY DO I SURE ENJOY TRASH. THERE'S NOTHING MORE I LOVE THAN TO SIT DOWN IN FRONT OF THE BIG SCREEN AND EAT A BIIIIG STEAMY BOWL OF SHIT. WARNER BROS CAN COME OVER TO MY HOUSE AND ASSFUCK MY MOM WHILE I WATCH AND I WOULD CERTIFY IT FRESH, NO QUESTION

Knyteguy posted:

I'm not entirely sure if this is what you're looking for, but Web Essentials is great. If you don't have it yet it's pretty nice for bundling. So you can have all your separate files unminified in VS, and just point your includes/header references to the generated bundle file. If any actual compiling is necessary for modules or something I've just written plugins that run command line stuff first, which I'd imagine you could get to to work with the bundle if you needed to (you can configure when the bundle is generated).

e: took me a minute to get that phrasing how I wanted it.

Yeah it's the compiling of modules that I'm interested in, think I'll continue to use npm scripts with watchify/browserify since that works fairly well so far.

On a related note (kind of) I am trying to figure out how best to handle models in JS. Because JS really has no actual type enforcing I was wondering how people tend to keep their data models as consistent as possible? For example, if I want to use a "student" model in a few different places, is there some way to help me keep the properties consistent?

Mr Shiny Pants
Nov 12, 2012

The Wizard of Poz posted:

Yeah it's the compiling of modules that I'm interested in, think I'll continue to use npm scripts with watchify/browserify since that works fairly well so far.

On a related note (kind of) I am trying to figure out how best to handle models in JS. Because JS really has no actual type enforcing I was wondering how people tend to keep their data models as consistent as possible? For example, if I want to use a "student" model in a few different places, is there some way to help me keep the properties consistent?

Make a JS file with just your models in it and load it everywhere you need them?

Ahz
Jun 17, 2001
PUT MY CART BACK? I'M BETTER THAN THAT AND YOU! WHERE IS MY BUTLER?!
I'm looking for the simplest way to create an effect.

Essentially I want something like a simple carousel or rotating box, but I only want to rotate through simple web elements, like an inline div in a page. For example I might have key phrases I want to cycle through 20 or so, but I want the phrases to cycle through with a neat but simple animation, and the phrases themselves are a part of a larger inline phrase.

Another idea for a neat effect I would like to do for the rotating phrases is something where you have the main in-focus phrase to be at full opacity, but phrases before and after cycling through above and below, almost like a rotating globe / rotating dial effect where the prev/last few (4 or 5) start to come into view/focus before and after the focused div/phrase.

Any ideas?

aBagorn
Aug 26, 2004

Mr Shiny Pants posted:

Make a JS file with just your models in it and load it everywhere you need them?

I actually listened to a podcast this morning that suggested this very strategy. I like it.

Pollyanna
Mar 5, 2005

Milk's on them.


Anyone here use gulp? I'm trying to think of a way to make using it a little easier for me to handle.

As I understand it, gulp makes use of streams and piping to build/concatenate and watch files. The basic idea is that a source file is input, several transforms are placed upon it, and a finalized source file is output. For example, if I wanted to take a file app/main.js, run Browserify on it, Uglify it, then output it as bundle.js to a dist/src directory, it'd look something like this (adapted from here):

JavaScript code:
var browserify = require('browserify');
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');

gulp.task('browserify', function() {
  return browserify('./app/main.js')
    .bundle()
    .pipe(source('bundle.js'))
    .pipe(buffer())
    .pipe(uglify()) 
    .pipe(gulp.dest('./dist/src'));
});
This is kind of an ugly way to pipe the results of a function into another. To me, it's easier to understand like this:

code:

# |> is piping, -> is a method called on the previous argument after piping (fuckin' bundle())

(((('./app/main.js'
  |> browserify -> bundle), 'bundle.js')
  |> source
  |> buffer
  |> uglify), './dist/src')
  |> gulp-dest
In plain English, I:

  • pipe my source file into browserify, returning the result
  • call bundle() on the result of the previous operation, returning the result
  • pipe the result of the previous operation, along with the new file's filename, into source, returning the result
  • pipe the result of the previous operation into buffer, returning the result
  • pipe the result of the previous operation into uglify, returning the result
  • pipe the result of the previous operation, along with our dist/src directory, into dest.

This way, it's clear to see that it's a procedure with a set of transformations performed on a given input. If we conceptualize what gulp does as a series of transforms given certain inputs, with no regard to an overarching global state, then it's easy to think of it in a functional manner. All I ever really need to pass in are three pieces of data: my source file's location, the name of my output file, and the directory that new file will be in. So, I could break up that larger piping into pieces:

code:
: browserify-bundle (source-file)
  # we assume that each function returns something (puts it onto the "stack", maybe?)
  source-file
    |> browserify -> bundle

: bundle-source-to-buffer (source-file, new-file)
  (source-file
    |> browserify-bundle, new-file)
    |> source
    |> buffer

: uglify-bundle-buffer (source-file, new-file)
  (source-file, new-file)
    |> bundle-source-to-buffer
    |> uglify

: write-bundle-to-dest (source-file, new-file, file-destination)
  (source-file, new-file)
    |> uglify-bundle-buffer, file-destination)
    |> gulp-dest

# now we create our new task
(('./app/main.js', 'bundle.js', './dist/src')
  |> write-bundle-to-dest, "browserify")
  |> gulp-task
You could also do like I mentioned and take a stack based approach, since we're assuming that every function returns something - functions just act on n pieces of the stack at any time, and you add to the stack to add other inputs to a function. source-file new-file file-destination write-bundle-to-dest "browserify" gulp-task, or something.

Does this make sense? Personally this way is easier for me to express exactly what I want to happen when I make a gulp task: I just want to push something into a black box, and have something else come out the other end. I was hoping that an approach like this would work well, but it looks like stuff like bundle and streams throw a wrench into this plan...I think. I still have to think about how to actually implement something that takes advantage of this, too.

yes i did just start learning about functional programming and stack based languages, why do you ask

Mr Shiny Pants
Nov 12, 2012
Maybe you guys can help me with this, I just started with JS development and I am looking for a way to do the following:

I have inherited an application that uses its own collections and model binding that I am looking to extend.

This application uses a hierarchy of arrays and models within, a bit like thread, post and replies. So top model contains a collections of models that themselves have other models within them.

Can I use backbone for this? Can I have models that contain a collection of other models and still hook everything up with eventhandlers and the rerendering logic?

I've been reading up on Backbone and Ember but Ember is too much for me right now, so if Backbone can do it, it will save me some time.

RobertKerans
Aug 25, 2006

There is a heppy lend
Fur, fur aw-a-a-ay.

Eg you want Elixir's pipe operator. I hesitate to do this, but here's another thing you can learn http://livescript.net/. You are trying to replace chaining with chaining that looks more like Elixir/Haskell/F#/Scala and doesn't quite work the same because the language is not built to easily do the thing you want to do. The Gulpfile should be a simple config file, you don't need to do this

RobertKerans fucked around with this message at 11:55 on Feb 5, 2015

Stoph
Mar 19, 2006

Give a hug - save a life.

Pollyanna posted:

Anyone here use gulp? I'm trying to think of a way to make using it a little easier for me to handle.

As I understand it, gulp makes use of streams and piping to build/concatenate and watch files. The basic idea is that a source file is input, several transforms are placed upon it, and a finalized source file is output. For example, if I wanted to take a file app/main.js, run Browserify on it, Uglify it, then output it as bundle.js to a dist/src directory, it'd look something like this

Your response to writing a 14-line Gulpfile is to start designing a new programming language. Can you understand why your employer and/or coworkers would be a little worried about this?

Pollyanna
Mar 5, 2005

Milk's on them.


What employer and coworkers? I'm not even employed quite yet. And besides, I'm not actually going to implement this, it's just a thought experiment (unless somebody does want me to make it in which case I was completely serious).

RobertKerans
Aug 25, 2006

There is a heppy lend
Fur, fur aw-a-a-ay.

Pollyanna posted:

What employer and coworkers? I'm not even employed quite yet. And besides, I'm not actually going to implement this, it's just a thought experiment (unless somebody does want me to make it in which case I was completely serious).

I would like to be able to write Elixir/Erlang, and have access to something along the lines of clojurescript/scalajs. I'm happy to just have a macro based solution, so you'd could do something like have a hard dependency on sweet.js (and node, unfortunately), just until you can redo the compiler in Erlang/Elixir. Please make the DSL as close as is possible (maybe abstractions over web workers emulating processes, that kinda thing). Thanks! ;)

RobertKerans fucked around with this message at 22:54 on Feb 5, 2015

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy
I prototyped a Gulp-like tool written in PowerShell at work a while ago. It was actually pretty straightforward, PS' pipeline model is pretty powerful and friendly. The end result was a set of building blocks that could be used like:

code:
Get-ChildItem *.js | Concat-Files | Minify-Js | Out-File app.js
So maybe you'd be happy with something like that.

Quebec Bagnet fucked around with this message at 06:26 on Feb 6, 2015

Kobayashi
Aug 13, 2004

by Nyc_Tattoo
I've hosed around with Gulp and Grunt and Broccoli a little, and when I have a choice, I just end up using NPM scripts. Chaining together what are essentially a bunch of simple shell commands is, at worst, no more time consuming than whatever weird bugs and incompatibilities I'd inevitably run into with dedicated task runners.

RobertKerans
Aug 25, 2006

There is a heppy lend
Fur, fur aw-a-a-ay.
Grunt/Gulp are fantastic for design, where a fairly large set of scripts all doing specific things to a prototype are necessary. But for most dev tasks, yeah, NPM scripts are generally better.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Mr Shiny Pants posted:

Can I use backbone for this? Can I have models that contain a collection of other models and still hook everything up with eventhandlers and the rerendering logic?

I haven't done anything with Backbone for a couple of years, but back then, Backbone didn't have native support for nested models. I don't know if that has changed. There were extensions that added that, but I haven't used them.

Ochowie
Nov 9, 2007

Has anyone here worked with the boostrap-ui tools for Angular? I'm using the modal functionality and it seems like the modal window doesn't inherit the parent's scope like a normal Angular controller does. Is there any way around this? I have a view that I'd like to reuse as a modal pop-up , however the view uses some data from the parent scope and that data is not coming through when the view is launched as a modal. Is there any way around this or do I really have to create a separate controller that takes in the scope object I'd like to share?

SuicideSnowman
Jul 26, 2003

Ochowie posted:

Has anyone here worked with the boostrap-ui tools for Angular? I'm using the modal functionality and it seems like the modal window doesn't inherit the parent's scope like a normal Angular controller does. Is there any way around this? I have a view that I'd like to reuse as a modal pop-up , however the view uses some data from the parent scope and that data is not coming through when the view is launched as a modal. Is there any way around this or do I really have to create a separate controller that takes in the scope object I'd like to share?

You can pass data through to modal with resolve:

code:
var modalInstance = $modal.open({
      templateUrl: 'myModalContent.html',
      controller: 'ModalInstanceCtrl',
      size: size,
      resolve: {
        items: function () {
          return $scope.items;
        }
      }
    });
Then in the controller for the modal just do something like:

code:
controller('ModalInstanceCtrl', function($scope, $modalInstance, items) {
	$scope.items = items;
});
Then when you access or change $scope.items in the modal those changes will be reflected in the original as well. This code is taken from the bootstrap-ui documentation.

Ochowie
Nov 9, 2007

SuicideSnowman posted:

You can pass data through to modal with resolve:

code:
var modalInstance = $modal.open({
      templateUrl: 'myModalContent.html',
      controller: 'ModalInstanceCtrl',
      size: size,
      resolve: {
        items: function () {
          return $scope.items;
        }
      }
    });
Then in the controller for the modal just do something like:

code:
controller('ModalInstanceCtrl', function($scope, $modalInstance, items) {
	$scope.items = items;
});
Then when you access or change $scope.items in the modal those changes will be reflected in the original as well. This code is taken from the bootstrap-ui documentation.

I was hoping to use the same controller as the non-modal version.

Kobayashi
Aug 13, 2004

by Nyc_Tattoo

RobertKerans posted:

Grunt/Gulp are fantastic for design, where a fairly large set of scripts all doing specific things to a prototype are necessary. But for most dev tasks, yeah, NPM scripts are generally better.

I'm a designer, I'd love to hear some examples of how you're using those tools to prototype...

SuicideSnowman
Jul 26, 2003

Ochowie posted:

I was hoping to use the same controller as the non-modal version.

Sorry, I read your question wrong. In that case, no I don't believe you can do that. You have to pass objects with resolve.

https://uithought.wordpress.com/2014/09/23/use-the-same-controller-for-modal-and-non-modal-template-in-angular-ui-bootstrap/

There's a possible solution.

Mr Shiny Pants
Nov 12, 2012

Wheany posted:

I haven't done anything with Backbone for a couple of years, but back then, Backbone didn't have native support for nested models. I don't know if that has changed. There were extensions that added that, but I haven't used them.

This is what I was afraid off, I've looked at Backbone relational but that is another layer I need to learn.

I took the plunge and installed Ember.js. We'll see how it goes. Ember.data looks promising.

Thanks.

Ochowie
Nov 9, 2007

SuicideSnowman posted:

Sorry, I read your question wrong. In that case, no I don't believe you can do that. You have to pass objects with resolve.

https://uithought.wordpress.com/2014/09/23/use-the-same-controller-for-modal-and-non-modal-template-in-angular-ui-bootstrap/

There's a possible solution.

That helped. I didn't know you could pass a scope to the modal separately, so I added the shared object to the scope and passed it to the modal and that worked. Now the controller is the same for both display modes.

Workaday Wizard
Oct 23, 2009

by Pragmatica
I am reading the flux todo list tutorial at: http://facebook.github.io/flux/docs/todo-list.html#content

Can someone explain to me the purpose of "Object.assign" in this line:
JavaScript code:
Dispatcher.prototype = assign({}, Dispatcher.prototype, {

Why use it instead of good old assignments?

Adbot
ADBOT LOVES YOU

Huragok
Sep 14, 2011

Shinku ABOOKEN posted:

Why use it instead of good old assignments?

quote:

The Object.assign() method is used to copy the values of all enumerable own properties from one or more source objects to a target object. It will return the target object.
MDN

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply