Two minor nits that don't affect completion


#1

I reported these as bugs, but thought I'd post them here as well. Please correct me if I'm wrong:

a) In "installApp I", step 3, the comma operator on the 2nd and 3rd lines is unnecessary and confusing,

scope.buttonText = "Install",
scope.installed = false,

They should be semicolons:

scope.buttonText = "Install";
scope.installed = false;

b) The main.css defines ".btn-downloaded" but not ".btn-active"; perhaps the latter was intended?

Even if I tweak the .css, the behavior is not quite right, perhaps because element.toggleClass() toggles the install-app element, not the button element. What's the point of that?


#2

I posted a question specifically about .btn-active bc this one hasn't gotten a response.

I was also curious about commas vs. semicolons on this problem but I think that when you're defining properties of an object in JS you are supposed to use commas after each prop. It gets confusing because we access those props using the same dot notation in the function definition (see below code) which is a property of the object but at that point we're in a function not an object def (in terms of the local scope). Does that seem right?

app.directive('installApp', function() {
  return {
    restrict: "E",
    scope: {
      
    },
    templateUrl: 'js/directives/installApp.html',
    link: function(scope, element, attrs) {
      scope.buttonText = "Install",
      scope.installed = false,
      
      scope.download = function() {
        element.toggleClass('btn-active')
        if(scope.installed) {
          scope.buttonText = "Install";
          scope.installed = false;
        } else {
          scope.buttonText = "Uninstall";
          scope.installed = true;
        }
      }
    }
  };
});

#3

The return value is an object, so everything inside is either a property or a method. Properties, including methods are separated by a comma.

However,

is a function with statements, not properties. These two lines get semi-colons.

And, since,

scope.download = function() {

where the assigned value is an expression, it ends with a semi-colon as well (its the third line from the bottom.


#4

Interesting but is making sense.

To clarify, everything inside the .link() method should have semicolons? Meaning there was a mistake in the original code? Those commas were placed there by Codecademy.


#5

Can you please post a link to this lesson? Thank you.


#6

https://www.codecademy.com/en/courses/learn-angularjs/lessons/directives/exercises/directives-generalizations


#7

The issue, as it were, is in the part of the courseware that we cannot create a PR for so will have to hand this one upstairs.


#8

Update: I spoke with an Advisor concerning the commas and am told that commas or semi-colons are both okay to use. I'm still scratching my head, but not one to argue. Still up in the air on this question.

As to the brn-active class, it is supposed to be in main styles. At some point it may reappear in the CSS. The team has been advised.